mirror of https://github.com/n1nj4sec/pupy.git
Fix async dispatch
This commit is contained in:
parent
9c4bd4e680
commit
ef9a89a14f
|
@ -38,10 +38,10 @@ class PupyConnection(Connection):
|
||||||
else:
|
else:
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def _send_request(self, handler, args, async=False):
|
def _send_request(self, handler, args, async=None):
|
||||||
seq = next(self._seqcounter)
|
seq = next(self._seqcounter)
|
||||||
if async:
|
if async:
|
||||||
self._async_callbacks[seq] = callback
|
self._async_callbacks[seq] = async
|
||||||
else:
|
else:
|
||||||
self._sync_events[seq] = Event()
|
self._sync_events[seq] = Event()
|
||||||
|
|
||||||
|
@ -49,17 +49,18 @@ class PupyConnection(Connection):
|
||||||
return seq
|
return seq
|
||||||
|
|
||||||
def _async_request(self, handler, args = (), callback = (lambda a, b: None)):
|
def _async_request(self, handler, args = (), callback = (lambda a, b: None)):
|
||||||
seq = self._send_request(handler, args)
|
self._send_request(handler, args, async=callback)
|
||||||
return seq
|
|
||||||
|
|
||||||
def _dispatch_reply(self, seq, raw):
|
def _dispatch_reply(self, seq, raw):
|
||||||
|
sync = seq not in self._async_callbacks
|
||||||
Connection._dispatch_reply(self, seq, raw)
|
Connection._dispatch_reply(self, seq, raw)
|
||||||
if not seq in self._async_callbacks:
|
if sync:
|
||||||
self._sync_events[seq].set()
|
self._sync_events[seq].set()
|
||||||
|
|
||||||
def _dispatch_exception(self, seq, raw):
|
def _dispatch_exception(self, seq, raw):
|
||||||
|
sync = seq not in self._async_callbacks
|
||||||
Connection._dispatch_exception(self, seq, raw)
|
Connection._dispatch_exception(self, seq, raw)
|
||||||
if not seq in self._async_callbacks:
|
if sync:
|
||||||
self._sync_events[seq].set()
|
self._sync_events[seq].set()
|
||||||
|
|
||||||
class PupyTCPServer(ThreadedServer):
|
class PupyTCPServer(ThreadedServer):
|
||||||
|
|
Loading…
Reference in New Issue