diff options
author | csboling <csboling@users.noreply.github.com> | 2016-04-29 21:19:13 -0400 |
---|---|---|
committer | csboling <csboling@users.noreply.github.com> | 2016-04-29 21:19:13 -0400 |
commit | b6fdbaacb0d1546d20f36909f839aac7e7f0f0fa (patch) | |
tree | 2fcd11a0a26411e677b9c1f2711d7b24c980ca63 /serial | |
parent | bf6d3aa171f1e626619d494b5abe1981db20af20 (diff) | |
download | pyserial-git-b6fdbaacb0d1546d20f36909f839aac7e7f0f0fa.tar.gz |
raise exceptions in connection_lost
Default connection_lost behavior swallowed all exceptions that occurred while a ReaderThread was running, sometimes making a client Protocol difficult to debug. This patch instead raises an exception if one occurred.
Diffstat (limited to 'serial')
-rw-r--r-- | serial/threaded/__init__.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/serial/threaded/__init__.py b/serial/threaded/__init__.py index 5fd3bc9..2952166 100644 --- a/serial/threaded/__init__.py +++ b/serial/threaded/__init__.py @@ -30,6 +30,8 @@ class Protocol(object): Called when the serial port is closed or the reader loop terminated otherwise. """ + if isinstance(exc, Exception): + raise exc class Packetizer(Protocol): @@ -53,6 +55,7 @@ class Packetizer(Protocol): def connection_lost(self, exc): """Forget transport""" self.transport = None + super().connection_lost(exc) def data_received(self, data): """Buffer received data, find TERMINATOR, call handle_packet""" @@ -90,6 +93,7 @@ class FramedPacket(Protocol): self.transport = None self.in_packet = False del self.packet[:] + super().connection_lost(exc) def data_received(self, data): """Find data enclosed in START/STOP, call handle_packet""" |