Skip to content

Commit

Permalink
Replaced finally block with else and generalized the except block for…
Browse files Browse the repository at this point in the history
… non-EOFError to release lock---fixes test_affinity.Test_Affinity locally
  • Loading branch information
comrumino committed Jul 2, 2022
1 parent b24257f commit 1936e9b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions rpyc/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,24 @@ def serve(self, timeout=1, wait_for_lock=True): # serving
return False
# Assume the receive rlock is acquired and incremented
try:
data = None # Ensure data is initialized
data = self._channel.poll(timeout) and self._channel.recv()
if not data:
return False
except EOFError:
self.close() # sends close async request
except Exception as exc:
if isinstance(exc, EOFError):
self.close() # sends close async request
self._recvlock.release()
with self._recv_event:
self._recv_event.notify_all()
raise
finally:
else:
self._recvlock.release()
with self._recv_event:
self._recv_event.notify_all()
self._dispatch(data)
return True
if not data:
return False
else:
self._dispatch(data)
return True

def poll(self, timeout=0): # serving
"""Serves a single transaction, should one arrives in the given
Expand Down

0 comments on commit 1936e9b

Please sign in to comment.