From f0f6b18f42c7b9a2d4f9806b854849ae2202d547 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 4 Feb 2017 22:32:13 -0800 Subject: [PATCH] minor fixes to zeromq support --- socketio/zmq_manager.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/socketio/zmq_manager.py b/socketio/zmq_manager.py index 3950655..d8995a0 100644 --- a/socketio/zmq_manager.py +++ b/socketio/zmq_manager.py @@ -5,6 +5,7 @@ try: import eventlet.green.zmq as zmq except ImportError: zmq = None +import six from .pubsub_manager import PubSubManager @@ -12,6 +13,9 @@ from .pubsub_manager import PubSubManager class ZmqManager(PubSubManager): # pragma: no cover """zmq based client manager. + NOTE: this zmq implementation should be considered experimental at this + time. At this time, eventlet is required to use zmq. + This class implements a zmq backend for event sharing across multiple processes. To use a zmq backend, initialize the :class:`Server` instance as follows:: @@ -27,25 +31,20 @@ class ZmqManager(PubSubManager): # pragma: no cover default of ``False`` initializes the class for emitting and receiving. + A zmq message broker must be running for the zmq_manager to work. + you can write your own or adapt one from the following simple broker + below:: - N.B. - a zmq message broker must be running for the zmq_manager to work. - you can write your own or adapt one from the following simple broker below. - port numbers in the broker must match port numbers in connection string. - `` - import zmq - - receiver = zmq.Context().socket(zmq.PULL) - receiver.bind("tcp://*:5555") + import zmq - publisher = zmq.Context().socket(zmq.PUB) - publisher.bind("tcp://*:5556") + receiver = zmq.Context().socket(zmq.PULL) + receiver.bind("tcp://*:5555") + publisher = zmq.Context().socket(zmq.PUB) + publisher.bind("tcp://*:5556") - while True: - publisher.send(receiver.recv()) - `` - + while True: + publisher.send(receiver.recv()) """ name = 'zmq' @@ -97,7 +96,7 @@ class ZmqManager(PubSubManager): # pragma: no cover def _listen(self): for message in self.zmq_listen(): - if isinstance(message, str): + if isinstance(message, six.binary_type): try: message = pickle.loads(message) except Exception: