Created
March 8, 2013 20:41
-
-
Save lopter/5119676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/zerorpc/context.py b/zerorpc/context.py | |
index 8d8f5f0..f489509 100644 | |
--- a/zerorpc/context.py | |
+++ b/zerorpc/context.py | |
@@ -32,15 +32,6 @@ import gevent_zmq as zmq | |
class Context(zmq.Context): | |
_instance = None | |
- # Since pyzmq 13.0.0 implicit assignation is forbidden. Thankfully we are | |
- # allowed to define our attributes here, and initialize them per instance | |
- # later. | |
- _middlewares = None | |
- _hooks = None | |
- _msg_id_base = None | |
- _msg_id_counter = None | |
- _msg_id_counter_stop = None | |
- | |
def __init__(self): | |
super(zmq.Context, self).__init__() | |
self._middlewares = [] | |
@@ -57,6 +48,50 @@ class Context(zmq.Context): | |
} | |
self._reset_msgid() | |
+ # NOTE: pyzmq 13.0.0 messed up with setattr (they turned it into a | |
+ # non-op) and you can't assign attributes normally anymore, hence the | |
+ # tricks with self.__dict__ here | |
+ | |
+ @property | |
+ def _middlewares(self): | |
+ return self.__dict__['_middlewares'] | |
+ | |
+ @_middlewares.setter | |
+ def _middlewares(self, value): | |
+ self.__dict__['_middlewares'] = value | |
+ | |
+ @property | |
+ def _hooks(self): | |
+ return self.__dict__['_hooks'] | |
+ | |
+ @_hooks.setter | |
+ def _hooks(self, value): | |
+ self.__dict__['_hooks'] = value | |
+ | |
+ @property | |
+ def _msg_id_base(self): | |
+ return self.__dict__['_msg_id_base'] | |
+ | |
+ @_msg_id_base.setter | |
+ def _msg_id_base(self, value): | |
+ self.__dict__['_msg_id_base'] = value | |
+ | |
+ @property | |
+ def _msg_id_counter(self): | |
+ return self.__dict__['_msg_id_counter'] | |
+ | |
+ @_msg_id_counter.setter | |
+ def _msg_id_counter(self, value): | |
+ self.__dict__['_msg_id_counter'] = value | |
+ | |
+ @property | |
+ def _msg_id_counter_stop(self): | |
+ return self.__dict__['_msg_id_counter_stop'] | |
+ | |
+ @_msg_id_counter_stop.setter | |
+ def _msg_id_counter_stop(self, value): | |
+ self.__dict__['_msg_id_counter_stop'] = value | |
+ | |
@staticmethod | |
def get_instance(): | |
if Context._instance is None: | |
diff --git a/zerorpc/gevent_zmq.py b/zerorpc/gevent_zmq.py | |
index 6bd9231..d17e49a 100644 | |
--- a/zerorpc/gevent_zmq.py | |
+++ b/zerorpc/gevent_zmq.py | |
@@ -47,9 +47,9 @@ class Socket(_zmq.Socket): | |
def __init__(self, context, socket_type): | |
super(Socket, self).__init__(context, socket_type) | |
on_state_changed_fd = self.getsockopt(_zmq.FD) | |
- # Since pyzmq 13.0.0 implicit assignation is forbidden. Trying to define | |
- # the attributes as a class member first do not work either because the | |
- # setattr is a non-op! So we are doing it the ugly way. | |
+ # NOTE: pyzmq 13.0.0 messed up with setattr (they turned it into a | |
+ # non-op) and you can't assign attributes normally anymore, hence the | |
+ # tricks with self.__dict__ here | |
self.__dict__["_readable"] = gevent.event.Event() | |
self.__dict__["_writable"] = gevent.event.Event() | |
try: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment