From ef9a89a14f379ee9e9614099e8be2095aec31a67 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Wed, 19 Oct 2016 08:11:30 +0300 Subject: [PATCH] Fix async dispatch --- pupy/network/lib/servers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pupy/network/lib/servers.py b/pupy/network/lib/servers.py index 99612441..ce075c5d 100755 --- a/pupy/network/lib/servers.py +++ b/pupy/network/lib/servers.py @@ -38,10 +38,10 @@ class PupyConnection(Connection): else: return obj - def _send_request(self, handler, args, async=False): + def _send_request(self, handler, args, async=None): seq = next(self._seqcounter) if async: - self._async_callbacks[seq] = callback + self._async_callbacks[seq] = async else: self._sync_events[seq] = Event() @@ -49,17 +49,18 @@ class PupyConnection(Connection): return seq def _async_request(self, handler, args = (), callback = (lambda a, b: None)): - seq = self._send_request(handler, args) - return seq + self._send_request(handler, args, async=callback) def _dispatch_reply(self, seq, raw): + sync = seq not in self._async_callbacks Connection._dispatch_reply(self, seq, raw) - if not seq in self._async_callbacks: + if sync: self._sync_events[seq].set() def _dispatch_exception(self, seq, raw): + sync = seq not in self._async_callbacks Connection._dispatch_exception(self, seq, raw) - if not seq in self._async_callbacks: + if sync: self._sync_events[seq].set() class PupyTCPServer(ThreadedServer):