Author: rhs
Date: Mon Jun 16 16:25:01 2008
New Revision: 668344

URL: http://svn.apache.org/viewvc?rev=668344&view=rev
Log:
QPID-1142: made session.sync() always set the sync flag on execution_sync

Modified:
    incubator/qpid/trunk/qpid/python/qpid/session.py
    incubator/qpid/trunk/qpid/python/tests/connection.py

Modified: incubator/qpid/trunk/qpid/python/qpid/session.py
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/session.py?rev=668344&r1=668343&r2=668344&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/session.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/session.py Mon Jun 16 16:25:01 2008
@@ -91,10 +91,11 @@
       return tuple(exc)
 
   def sync(self, timeout=None):
-    if currentThread() == self.channel.connection.thread:
+    ch = self.channel
+    if ch is not None and currentThread() == ch.connection.thread:
       raise SessionException("deadlock detected")
     if not self.auto_sync:
-      self.execution_sync()
+      self.execution_sync(sync=True)
     last = self.sender.next_id - 1
     if not wait(self.condition, lambda:
                   last in self.sender._completed or self.exceptions,
@@ -174,10 +175,11 @@
     else:
       message = None
 
+    hdr = Struct(self.spec["session.header"])
+    hdr.sync = self.auto_sync or kwargs.pop("sync", False)
+
     cmd = type.new(args, kwargs)
     sc = StringCodec(self.spec)
-    hdr = Struct(self.spec["session.header"])
-    hdr.sync = self.auto_sync
     sc.write_command(hdr, cmd)
 
     seg = Segment(True, (message == None or

Modified: incubator/qpid/trunk/qpid/python/tests/connection.py
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests/connection.py?rev=668344&r1=668343&r2=668344&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests/connection.py (original)
+++ incubator/qpid/trunk/qpid/python/tests/connection.py Mon Jun 16 16:25:01 
2008
@@ -48,6 +48,9 @@
     self.session = session
     self.queue = queue
 
+  def execution_sync(self, es):
+    pass
+
   def queue_query(self, qq):
     return qq._type.result.type.new((qq.queue,), {})
 
@@ -90,8 +93,11 @@
     connect("0.0.0.0", PORT).close()
     self.server.join(3)
 
+  def connect(self):
+    return Connection(connect("0.0.0.0", PORT), self.spec)
+
   def test(self):
-    c = Connection(connect("0.0.0.0", PORT), self.spec)
+    c = self.connect()
     c.start(10)
 
     ssn1 = c.session("test1", timeout=10)
@@ -144,7 +150,7 @@
     c.close(5)
 
   def testCloseGet(self):
-    c = Connection(connect("0.0.0.0", PORT), self.spec)
+    c = self.connect()
     c.start(10)
     ssn = c.session("test", timeout=10)
     echos = ssn.incoming("echo")
@@ -166,7 +172,7 @@
       pass
 
   def testCloseListen(self):
-    c = Connection(connect("0.0.0.0", PORT), self.spec)
+    c = self.connect()
     c.start(10)
     ssn = c.session("test", timeout=10)
     echos = ssn.incoming("echo")
@@ -198,3 +204,11 @@
       assert m.body == "test%d" % i
 
     assert len(exceptions) == 1
+
+  def testSync(self):
+    c = self.connect()
+    c.start(10)
+    s = c.session("test")
+    s.auto_sync = False
+    s.message_transfer("echo", message=Message("test"))
+    s.sync(10)


Reply via email to