[Python-modules-commits] [txzmq] 02/11: Import txzmq_0.7.4.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Fri May 20 18:06:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository txzmq.

commit 1e765c935956056d487ff3ff124e068d4e773d39
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri May 20 17:52:00 2016 +0200

    Import txzmq_0.7.4.orig.tar.gz
---
 PKG-INFO                            |  2 +-
 VERSION                             |  2 +-
 txzmq/factory.py                    | 10 ++++++++-
 txzmq/pubsub.py                     |  2 +-
 txzmq/req_rep.py                    |  4 ++--
 txzmq/test/test_reactor_shutdown.py | 41 +++++++++++++++++++++++++++++++++++++
 6 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 805e840..f0cb673 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: txZMQ
-Version: 0.7.3
+Version: 0.7.4
 Summary: Twisted bindings for ZeroMQ
 Home-page: https://github.com/smira/txZMQ
 Author: Andrey Smirnov
diff --git a/VERSION b/VERSION
index f38fc53..0a1ffad 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.3
+0.7.4
diff --git a/txzmq/factory.py b/txzmq/factory.py
index 0b218b0..bb3442d 100644
--- a/txzmq/factory.py
+++ b/txzmq/factory.py
@@ -27,6 +27,7 @@ class ZmqFactory(object):
     reactor = reactor
     ioThreads = 1
     lingerPeriod = 100
+    trigger = None
 
     def __init__(self):
         """
@@ -55,6 +56,11 @@ class ZmqFactory(object):
 
         self.context.term()
         self.context = None
+        if self.trigger:
+            try:
+                self.reactor.removeSystemEventTrigger(self.trigger)
+            except Exception:
+                pass  # just ignore while triggered by the reactor
 
     def registerForShutdown(self):
         """
@@ -64,4 +70,6 @@ class ZmqFactory(object):
         It is recommended that this method is called on any
         created factory.
         """
-        reactor.addSystemEventTrigger('during', 'shutdown', self.shutdown)
+        self.trigger = self.reactor.addSystemEventTrigger(
+            'during', 'shutdown', self.shutdown
+        )
diff --git a/txzmq/pubsub.py b/txzmq/pubsub.py
index 064fe37..5813cdd 100644
--- a/txzmq/pubsub.py
+++ b/txzmq/pubsub.py
@@ -14,7 +14,7 @@ class ZmqPubConnection(ZmqConnection):
     """
     socketType = constants.PUB
 
-    def publish(self, message, tag=''):
+    def publish(self, message, tag=b''):
         """
         Publish `message` with specified `tag`.
 
diff --git a/txzmq/req_rep.py b/txzmq/req_rep.py
index f46700a..70dfc2d 100644
--- a/txzmq/req_rep.py
+++ b/txzmq/req_rep.py
@@ -159,8 +159,8 @@ class ZmqREPConnection(ZmqConnection):
 
         :param messageId: message uuid
         :type messageId: str
-        :param message: message data
-        :type message: str
+        :param messageParts: message data
+        :type messageParts: list
         """
         routingInfo = self._routingInfo.pop(messageId)
         self.send(routingInfo + [messageId, b''] + list(messageParts))
diff --git a/txzmq/test/test_reactor_shutdown.py b/txzmq/test/test_reactor_shutdown.py
new file mode 100644
index 0000000..9f650e8
--- /dev/null
+++ b/txzmq/test/test_reactor_shutdown.py
@@ -0,0 +1,41 @@
+"""
+Tests for L{txzmq.factory} automatic shutdown.
+"""
+from txzmq.factory import ZmqFactory
+
+from twisted.internet.test.reactormixins import ReactorBuilder
+from twisted.internet.interfaces import IReactorCore
+
+
+class ZmqReactorShutdownTestCase(ReactorBuilder):
+    """
+    Test case for L{zmq.twisted.factory.Factory}
+    automatic shutdown when the reactor is shutting down.
+    """
+
+    requiredInterfaces = (IReactorCore,)
+
+    def test_reactor_and_factory_shutdown(self):
+        reactor = self.buildReactor()
+
+        def _test():
+            factory = ZmqFactory()
+            factory.reactor = reactor
+            factory.registerForShutdown()
+            factory.shutdown()
+            reactor.stop()
+        reactor.callWhenRunning(_test)
+        reactor.run()
+
+    def test_reactor_shutdown(self):
+        reactor = self.buildReactor()
+
+        def _test():
+            factory = ZmqFactory()
+            factory.reactor = reactor
+            factory.registerForShutdown()
+            reactor.stop()
+        reactor.callWhenRunning(_test)
+        reactor.run()
+
+globals().update(ZmqReactorShutdownTestCase.makeTestCaseClasses())

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/txzmq.git



More information about the Python-modules-commits mailing list