Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 798cd07

Browse files
committed
improved message for TimoutExpired exception
1 parent 395dda1 commit 798cd07

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

gevent_zerorpc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ class LostRemote(Exception):
2020
pass
2121

2222
class TimeoutExpired(Exception):
23-
pass
23+
24+
def __init__(self, timeout_s, when=None):
25+
msg = 'timeout after {0}s'
26+
if when:
27+
msg = '{0}, when {1}'.format(msg, when)
28+
super(TimeoutExpired, self).__init__(msg)
2429

2530
class RemoteError(Exception):
2631

@@ -810,8 +815,9 @@ def _process_response(self, method, socket, timeout):
810815
try:
811816
try:
812817
event = socket.recv(timeout)
813-
except gevent.queue.Empty:
814-
raise TimeoutExpired(method, timeout)
818+
except TimeoutExpired:
819+
raise TimeoutExpired(timeout,
820+
'calling remote method {0}'.format(method))
815821

816822
pattern = self._select_pattern(event)
817823
return pattern.process_answer(socket, event, method, timeout,

0 commit comments

Comments
 (0)