Fix error on wait_for_response timeout.

Using pyee 1.0.1 handlers registered with once can't be removed. This handles the value error raised in this case.
pull/1513/head
Åke Forslund 2018-03-06 09:46:50 +01:00 committed by Matthew D. Scholefield
parent de6d3e2f11
commit 27fcd63e96
1 changed files with 8 additions and 1 deletions

View File

@ -123,7 +123,14 @@ class WebsocketClient(object):
while len(response) == 0:
time.sleep(0.2)
if monotonic.monotonic() - start_time > (timeout or 3.0):
self.remove(reply_type, handler)
try:
self.remove(reply_type, handler)
except (ValueError, KeyError):
# ValueError occurs on pyee 1.0.1 removing handlers
# registered with once.
# KeyError may theoretically occur if the event occurs as
# the handler is removbed
pass
return None
return response[0]