mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Add support for un-registering the on_recv
This commit is contained in:
parent
1392cd6638
commit
e11a914cb2
@ -250,15 +250,23 @@ class ZeroMQPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.transp
|
|||||||
'message from master').format(len(messages_len)))
|
'message from master').format(len(messages_len)))
|
||||||
return self._decode_payload(payload)
|
return self._decode_payload(payload)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stream(self):
|
||||||
|
if not hasattr(self, '_stream'):
|
||||||
|
self._stream = zmq.eventloop.zmqstream.ZMQStream(self._socket, io_loop=self.io_loop)
|
||||||
|
return self._stream
|
||||||
|
|
||||||
def on_recv(self, callback):
|
def on_recv(self, callback):
|
||||||
'''
|
'''
|
||||||
Register a callback for recieved messages (that we didn't initiate)
|
Register a callback for recieved messages (that we didn't initiate)
|
||||||
'''
|
'''
|
||||||
self.stream = zmq.eventloop.zmqstream.ZMQStream(self._socket, io_loop=self.io_loop)
|
if callback is None:
|
||||||
|
return self.stream.on_recv(None)
|
||||||
|
|
||||||
def wrap_callback(messages):
|
def wrap_callback(messages):
|
||||||
payload = self._decode_messages(messages)
|
payload = self._decode_messages(messages)
|
||||||
callback(payload)
|
callback(payload)
|
||||||
self.stream.on_recv(wrap_callback)
|
return self.stream.on_recv(wrap_callback)
|
||||||
|
|
||||||
def recv(self, timeout=0):
|
def recv(self, timeout=0):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user