diff options
author | 2015-08-24 18:44:56 +0300 | |
---|---|---|
committer | 2015-08-24 18:44:56 +0300 | |
commit | 98bc71b1c21452c3d868c4a4d418a8aeaa5a43af (patch) | |
tree | 2e66b9a775f0a5c545caa76f62890f5a5546e231 /external_libs/python/zmq/auth/ioloop.py | |
parent | 20eb7d362f9bce1951bd61ad3f78cf8f4267d1d5 (diff) | |
parent | 36c6c87fe4380b214f8ff8a45dc0213fa109821c (diff) |
Merge branch 'master' into dan_stateless
Diffstat (limited to 'external_libs/python/zmq/auth/ioloop.py')
-rw-r--r-- | external_libs/python/zmq/auth/ioloop.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/external_libs/python/zmq/auth/ioloop.py b/external_libs/python/zmq/auth/ioloop.py new file mode 100644 index 00000000..1f448b47 --- /dev/null +++ b/external_libs/python/zmq/auth/ioloop.py @@ -0,0 +1,34 @@ +"""ZAP Authenticator integrated with the tornado IOLoop. + +.. versionadded:: 14.1 +""" + +# Copyright (C) PyZMQ Developers +# Distributed under the terms of the Modified BSD License. + +from zmq.eventloop import ioloop, zmqstream +from .base import Authenticator + + +class IOLoopAuthenticator(Authenticator): + """ZAP authentication for use in the tornado IOLoop""" + + def __init__(self, context=None, encoding='utf-8', log=None, io_loop=None): + super(IOLoopAuthenticator, self).__init__(context) + self.zap_stream = None + self.io_loop = io_loop or ioloop.IOLoop.instance() + + def start(self): + """Start ZAP authentication""" + super(IOLoopAuthenticator, self).start() + self.zap_stream = zmqstream.ZMQStream(self.zap_socket, self.io_loop) + self.zap_stream.on_recv(self.handle_zap_message) + + def stop(self): + """Stop ZAP authentication""" + if self.zap_stream: + self.zap_stream.close() + self.zap_stream = None + super(IOLoopAuthenticator, self).stop() + +__all__ = ['IOLoopAuthenticator'] |