Skip to content

Commit

Permalink
Make client disconnects more robust (Fixes miguelgrinberg/python-sock…
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Apr 9, 2020
1 parent e12f517 commit 4297eb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions engineio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,19 @@ async def _read_loop_websocket(self):
break
except Exception as e:
self.logger.info(
'Unexpected error "%s", aborting', str(e))
'Unexpected error receiving packet: "%s", aborting',
str(e))
await self.queue.put(None)
break
if isinstance(p, six.text_type): # pragma: no cover
p = p.encode('utf-8')
pkt = packet.Packet(encoded_packet=p)
try:
pkt = packet.Packet(encoded_packet=p)
except Exception as e: # pragma: no cover
self.logger.info(
'Unexpected error decoding packet: "%s", aborting', str(e))
await self.queue.put(None)
break
await self._receive_packet(pkt)

self.logger.info('Waiting for write loop task to end')
Expand Down
11 changes: 9 additions & 2 deletions engineio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,19 @@ def _read_loop_websocket(self):
break
except Exception as e:
self.logger.info(
'Unexpected error "%s", aborting', str(e))
'Unexpected error receiving packet: "%s", aborting',
str(e))
self.queue.put(None)
break
if isinstance(p, six.text_type): # pragma: no cover
p = p.encode('utf-8')
pkt = packet.Packet(encoded_packet=p)
try:
pkt = packet.Packet(encoded_packet=p)
except Exception as e: # pragma: no cover
self.logger.info(
'Unexpected error decoding packet: "%s", aborting', str(e))
self.queue.put(None)
break
self._receive_packet(pkt)

self.logger.info('Waiting for write loop task to end')
Expand Down

0 comments on commit 4297eb4

Please sign in to comment.