receiver: gracefully handle more receiver and device disconnects

This commit is contained in:
Peter F. Patel-Schneider 2020-11-06 08:36:35 -05:00
parent 6b8e7a2d9c
commit 66f3d5d02b
1 changed files with 11 additions and 2 deletions

View File

@ -388,7 +388,11 @@ def request(handle, devnumber, request_id, *params, no_reply=False, return_error
ihandle = int(handle)
notifications_hook = getattr(handle, 'notifications_hook', None)
_skip_incoming(handle, ihandle, notifications_hook)
try:
_skip_incoming(handle, ihandle, notifications_hook)
except NoReceiver:
_log.warn('device or receiver disconnected')
return None
write(ihandle, devnumber, request_data, long_message)
if no_reply:
@ -498,7 +502,12 @@ def ping(handle, devnumber, long_message=False):
ihandle = int(handle)
notifications_hook = getattr(handle, 'notifications_hook', None)
_skip_incoming(handle, ihandle, notifications_hook)
try:
_skip_incoming(handle, ihandle, notifications_hook)
except NoReceiver:
_log.warn('device or receiver disconnected')
return
write(ihandle, devnumber, request_data, long_message)
# we consider timeout from this point