Skip to content

Commit 742f491

Browse files
author
Neil Booth
committed
Better handle exceptions when notifying sessions
Based on #1022
1 parent 3cc50ee commit 742f491

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

electrumx/server/session.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,15 @@ def unsubscribe_hashX(self, hashX):
956956
return self.hashX_subs.pop(hashX, None)
957957

958958
async def notify(self, touched, height_changed):
959+
'''Wrap _notify_inner; websockets raises exceptions for unclear reasons.'''
960+
try:
961+
await self._notify_inner(touched, height_changed)
962+
except CancelledError:
963+
raise
964+
except Exception:
965+
self.logger.exception('unexpected exception notifying client')
966+
967+
async def _notify_inner(self, touched, height_changed):
959968
'''Notify the client about changes to touched addresses (from mempool
960969
updates or new blocks) and height.
961970
'''

0 commit comments

Comments
 (0)