Skip to content

Commit 812f269

Browse files
authored
Merge pull request #4 from davidko/master
Ignore termios.error when hot-unplugging USB-Serial devices
2 parents b4cfd5a + f5c3614 commit 812f269

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

serial_asyncio/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717
import asyncio
1818
import serial
19+
import termios
1920

2021

2122
__version__ = '0.1'
@@ -345,7 +346,12 @@ def _call_connection_lost(self, exc):
345346
assert self._closing
346347
assert not self._has_writer
347348
assert not self._has_reader
348-
self._serial.flush()
349+
try:
350+
self._serial.flush()
351+
except termios.error:
352+
# ignore termios errors which may happen if the serial device was
353+
# hot-unplugged.
354+
pass
349355
try:
350356
self._protocol.connection_lost(exc)
351357
finally:

0 commit comments

Comments
 (0)