You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2015/01/27 19:39:13 UTC
qpid-proton git commit: add handling of delivery state to blocking
send
Repository: qpid-proton
Updated Branches:
refs/heads/master b4d0135c0 -> 17cbce0f0
add handling of delivery state to blocking send
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/17cbce0f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/17cbce0f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/17cbce0f
Branch: refs/heads/master
Commit: 17cbce0f0933519eb4c98e8446ce93922aa6dd4f
Parents: b4d0135
Author: Gordon Sim <gs...@redhat.com>
Authored: Tue Jan 27 18:33:57 2015 +0000
Committer: Gordon Sim <gs...@redhat.com>
Committed: Tue Jan 27 18:34:07 2015 +0000
----------------------------------------------------------------------
proton-c/bindings/python/proton/utils.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/17cbce0f/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 65121ee..c34f5c7 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -17,7 +17,8 @@
# under the License.
#
import collections, Queue, socket, time, threading
-from proton import ConnectionException, Delivery, Endpoint, Handler, LinkException, Message, Timeout, Url
+from proton import ConnectionException, Delivery, Endpoint, Handler, LinkException, Message
+from proton import ProtonException, Timeout, Url
from proton.reactors import AmqpSocket, Container, Events, SelectLoop, send_msg
from proton.handlers import Acking, MessagingHandler, ScopedHandler, IncomingMessageHandler
@@ -39,6 +40,13 @@ class BlockingLink(object):
# Access to other link attributes.
def __getattr__(self, name): return getattr(self.link, name)
+class SendException(ProtonException):
+ """
+ Exception used to indicate an exceptional state/condition on a send request
+ """
+ def __init__(self, state):
+ self.state = state
+
class BlockingSender(BlockingLink):
def __init__(self, connection, sender):
super(BlockingSender, self).__init__(connection, sender)
@@ -46,9 +54,15 @@ class BlockingSender(BlockingLink):
self.link.close()
raise LinkException("Failed to open sender %s, target does not match" % self.link.name)
- def send_msg(self, msg, timeout=False):
+ def send_msg(self, msg, timeout=False, error_states=None):
delivery = send_msg(self.link, msg)
self.connection.wait(lambda: delivery.settled, msg="Sending on sender %s" % self.link.name, timeout=timeout)
+ bad = error_states
+ if bad is None:
+ bad = [Delivery.REJECTED, Delivery.RELEASED]
+ if delivery.remote_state in bad:
+ raise SendException(delivery.remote_state)
+ return delivery
class Fetcher(MessagingHandler):
def __init__(self, prefetch):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org