summaryrefslogtreecommitdiffstats
path: root/src/console/zmq/green/eventloop/ioloop.py
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-08-23 18:52:11 +0300
committerDan Klein <danklei@cisco.com>2015-08-23 18:52:11 +0300
commit651a7d779551e193bd9dbadbe8b2a02bdab231b4 (patch)
treea42cb5ab0eca820899f9fedf538eef8d83ad4383 /src/console/zmq/green/eventloop/ioloop.py
parent84bb24ace632141dd5ece01d5f4985239014f660 (diff)
parent3bfe53394f43a37ce02b09c6420751027c602047 (diff)
Merge branch 'master' into dan_latest
Diffstat (limited to 'src/console/zmq/green/eventloop/ioloop.py')
-rwxr-xr-xsrc/console/zmq/green/eventloop/ioloop.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/console/zmq/green/eventloop/ioloop.py b/src/console/zmq/green/eventloop/ioloop.py
new file mode 100755
index 00000000..e12fd5e9
--- /dev/null
+++ b/src/console/zmq/green/eventloop/ioloop.py
@@ -0,0 +1,33 @@
+from zmq.eventloop.ioloop import *
+from zmq.green import Poller
+
+RealIOLoop = IOLoop
+RealZMQPoller = ZMQPoller
+
+class IOLoop(RealIOLoop):
+
+ def initialize(self, impl=None):
+ impl = _poll() if impl is None else impl
+ super(IOLoop, self).initialize(impl)
+
+ @staticmethod
+ def instance():
+ """Returns a global `IOLoop` instance.
+
+ Most applications have a single, global `IOLoop` running on the
+ main thread. Use this method to get this instance from
+ another thread. To get the current thread's `IOLoop`, use `current()`.
+ """
+ # install this class as the active IOLoop implementation
+ # when using tornado 3
+ if tornado_version >= (3,):
+ PollIOLoop.configure(IOLoop)
+ return PollIOLoop.instance()
+
+
+class ZMQPoller(RealZMQPoller):
+ """gevent-compatible version of ioloop.ZMQPoller"""
+ def __init__(self):
+ self._poller = Poller()
+
+_poll = ZMQPoller