qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject qpid-proton git commit: PROTON-825: fix blocking receive (also modified blocking helloworld example to use this)
Date Tue, 03 Mar 2015 17:31:18 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 8ea52ddd3 -> 048517947


PROTON-825: fix blocking receive (also modified blocking helloworld example to use this)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/04851794
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/04851794
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/04851794

Branch: refs/heads/master
Commit: 0485179476fba82414cc1d7871fd939a985a6ecd
Parents: 8ea52dd
Author: Gordon Sim <gsim@redhat.com>
Authored: Tue Mar 3 17:32:36 2015 +0000
Committer: Gordon Sim <gsim@redhat.com>
Committed: Tue Mar 3 17:32:36 2015 +0000

----------------------------------------------------------------------
 examples/python/helloworld_blocking.py   | 12 +++++-------
 proton-c/bindings/python/proton/utils.py |  6 ++++--
 2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/04851794/examples/python/helloworld_blocking.py
----------------------------------------------------------------------
diff --git a/examples/python/helloworld_blocking.py b/examples/python/helloworld_blocking.py
index d9a24a9..62b6105 100755
--- a/examples/python/helloworld_blocking.py
+++ b/examples/python/helloworld_blocking.py
@@ -22,14 +22,12 @@ from proton import Message
 from proton.utils import BlockingConnection
 from proton.handlers import IncomingMessageHandler
 
-class HelloWorldReceiver(IncomingMessageHandler):
-    def on_message(self, event):
-        print event.message.body
-        event.connection.close()
-
 conn = BlockingConnection("localhost:5672")
-conn.create_receiver("examples", handler=HelloWorldReceiver())
+receiver = conn.create_receiver("examples")
 sender = conn.create_sender("examples")
 sender.send(Message(body=u"Hello World!"));
-conn.run()
+msg = receiver.receive(timeout=30)
+print msg.body
+receiver.accept()
+conn.close()
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/04851794/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 d5e2e0a..fabe887 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -83,13 +83,15 @@ class BlockingSender(BlockingLink):
         return delivery
 
 class Fetcher(MessagingHandler):
-    def __init__(self, prefetch):
+    def __init__(self, connection, prefetch):
         super(Fetcher, self).__init__(prefetch=prefetch, auto_accept=False)
+        self.connection = connection
         self.incoming = collections.deque([])
         self.unsettled = collections.deque([])
 
     def on_message(self, event):
         self.incoming.append((event.message, event.delivery))
+        self.connection.container.yield_() # Wake up the wait() loop to handle the message.
 
     def on_link_error(self, event):
         if event.link.state & Endpoint.LOCAL_ACTIVE:
@@ -207,7 +209,7 @@ class BlockingConnection(Handler):
             if prefetch is None:
                 prefetch = 1
         else:
-            fetcher = Fetcher(credit)
+            fetcher = Fetcher(self, credit)
         return BlockingReceiver(
             self, self.container.create_receiver(self.conn, utf8(address), name=utf8(name),
dynamic=dynamic, handler=handler or fetcher, options=options), fetcher, credit=prefetch)
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message