Tell PySerial to cancel reads & writes on connection close
Only done if the methods needed for that exist and are callable though (to prevent issues with custom serial port implementations provided through hooks, or operating systems that don't have support for cancel_read/cancel_write in PySerial. Fixes #2333 (at least as far as we'll ever be able to fix it)
This commit is contained in:
1 parent
77989d2a76
commit
98b71a5870
1 file changed
+12
@@ -736,6 +736,18 @@ class MachineCom(object):
|
||||
|
||||
deactivate_monitoring_and_send_queue()
|
||||
|
||||
try:
|
||||
if hasattr(self._serial, "cancel_read") and callable(self._serial.cancel_read):
|
||||
self._serial.cancel_read()
|
||||
except:
|
||||
self._logger.exception("Error while cancelling pending reads from the serial port")
|
||||
|
||||
try:
|
||||
if hasattr(self._serial, "cancel_write") and callable(self._serial.cancel_write):
|
||||
self._serial.cancel_write()
|
||||
except:
|
||||
self._logger.exception("Error while cancelling pending writes to the serial port")
|
||||
|
||||
try:
|
||||
self._serial.close()
|
||||
except:
|
||||
|
||||
Reference in new issue
Block a user