diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 5d431d417..8f063bc83 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -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: