Re: Proton Python on_sendable behavior
On Tue, 2016-10-18 at 14:13 -0700, Justin Ross wrote: > https://gist.github.com/ssorj/1ccf4d1499563722bc419f1e1fac11bf > > In this example, there is still ample credit on the link after the > last > on_sendable() is printed, but on_sendable is never fired again. Is > that > expected behavior? > > It appears that on_link_flow is only fired when link credit is > updated, and > on_link_flow is the source of all on_sendable events. > > https://github.com/apache/qpid-proton/blob/master/proton-c/bindings/p > ython/proton/handlers.py#L36 There are two reasons a sender can block: running out of credit or running out of messages to send. If you run out of messages to send but still have credit, you need some non-proton way of being notified when there are more available. Proton will only give you an event when credit changes. E.g. in the broker examples (and the real broker) empty queues track senders that are blocked and wake them up when new messages arrive. In a single-threaded environment you can check credit and call sender.send() directly from queue code (the python broker does), but in a threaded broker you need to "inject" or somehow otherwise wake up the sender's thread context (like the C++ example does) since it will usually not be the same as the context that received the message. - To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org
Re: Proton Python on_sendable behavior
On 18 October 2016 at 22:13, Justin Ross wrote: > https://gist.github.com/ssorj/1ccf4d1499563722bc419f1e1fac11bf > > In this example, there is still ample credit on the link after the last > on_sendable() is printed, but on_sendable is never fired again. Is that > expected behavior? > > It appears that on_link_flow is only fired when link credit is updated, and > on_link_flow is the source of all on_sendable events. > > https://github.com/apache/qpid-proton/blob/master/proton-c/bindings/python/proton/handlers.py#L36 Thats my understanding from past discussion on these bits. Flow events are raised when a flow frame arrives from the peer, and also generated when sends occur on sending links, I believe to represent that 'credit has changed' (I added a flag in proton-j to allow disabling that, since it makes no sense in many cases). The on_sendable callback then fires when a flow event is handled and there is actually credit to send messages. If the last sendable callback is triggered and you dont have anything to send, then you wont get any more sendable callbacks until more credit arrives from the peer, which if you arent doing anything such as sending it messages, its likely it will never give. Essentially at that point you have been told there is credit to send messages, and its up to you to react and manage doing something to send them [on the container thread] once you do have something to send. - To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org
Re: Proton Python on_sendable behavior
- Original Message - > From: "Justin Ross" > To: users@qpid.apache.org > Sent: Tuesday, October 18, 2016 5:13:27 PM > Subject: Proton Python on_sendable behavior > > https://gist.github.com/ssorj/1ccf4d1499563722bc419f1e1fac11bf > > In this example, there is still ample credit on the link after the last > on_sendable() is printed, but on_sendable is never fired again. Is that > expected behavior? > > It appears that on_link_flow is only fired when link credit is updated, and > on_link_flow is the source of all on_sendable events. > > https://github.com/apache/qpid-proton/blob/master/proton-c/bindings/python/proton/handlers.py#L36 > When I run this code all messages go to the broker in one frame and the flow and dispositions come back in one frame: Frame 46 127.0.0.1:60006 -> 127.0.0.1:5672 -> transfer [0,0] (0..9) Frame 47 127.0.0.1:60006 <- 127.0.0.1:5672 <-flow [0,0] (10,500), disposition [0] (receiver 0-9) You have credit and just got some on_sendable callbacks. What's wrong with what you see? - To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org
Proton Python on_sendable behavior
https://gist.github.com/ssorj/1ccf4d1499563722bc419f1e1fac11bf In this example, there is still ample credit on the link after the last on_sendable() is printed, but on_sendable is never fired again. Is that expected behavior? It appears that on_link_flow is only fired when link credit is updated, and on_link_flow is the source of all on_sendable events. https://github.com/apache/qpid-proton/blob/master/proton-c/bindings/python/proton/handlers.py#L36