On 01/27/2015 02:55 PM, [email protected] wrote:
Repository: qpid-proton
Updated Branches:
   refs/heads/master c96f10736 -> 553023b95


NO-JIRA: Removed python "with" keyword from utils.py, not supported in jython.

In jython 2.5 I believe you have to use:

  from __future__ import with_statement

(Since jython is used only for testing, perhaps we could even upgrade?)

[...]
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/553023b9/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py 
b/proton-c/bindings/python/proton/utils.py
index 187fc29..65121ee 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -191,22 +191,26 @@ class BlockingConnection(Handler):
      def on_disconnected(self, event):
          raise ConnectionException("Connection %s disconnected" % self.url);

-def atomic_count(start=0, step=1):
-    """Thread-safe atomic count iterator"""
-    lock = threading.Lock()
-    count = start
-    while True:
-        with lock:
-            count += step;
-            yield count
-
+class AtomicCount(object):
+    def __init__(self, start=0, step=1):
+        """Thread-safe atomic counter. Start at start, increment by step."""
+        self.count, self.step = start, step
+        self.lock = threading.Lock()
+
+    def next(self):
+        """Get the next value"""
+        self.lock.acquire()
+        self.count += self.step;
+        result = self.count
+        self.lock.release()
+        return result

Why do you need an AtomicCount? The intent to allow concurrent requests I assume?

The underlying BlockingConnection and engine objects are not threadsafe, so if that assumption is correct you will need to prevent threads from concurrently accessing the same objects.


  class SyncRequestResponse(IncomingMessageHandler):
      """
      Implementation of the synchronous request-responce (aka RPC) pattern.
      """

-    correlation_id = atomic_count()
+    correlation_id = AtomicCount()

      def __init__(self, connection, address=None):
          """


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to