[Twisted-Python] "blocking" on a response to a client

Chris Withers chris at withers.org
Tue Nov 6 09:51:58 MST 2018


On 06/11/2018 13:47, Jean-Paul Calderone wrote:
>     Thanks, but the special bit I was asking about is having my
>     application's logical flow pause until the websocket is successfully up
>     and a successful response has been received, all without blocking the
>     reactor.
> 
>     How do I do that?
> 
> 
> Put the rest of your code in a callback on a Deferred that fires when 
> the event you're interested in happens.  When using inlineCallbacks, 
> that's like:
> 
>      yield the_event_youre_interested_in
>      # ... more code
> 
> At least, this is the extremely-localized solution to the problem.  
> There are many possible ways to structure such a thing.  It's easy to 
> describe this one because you said you're using inlineCallbacks and 
> didn't say anything else about how your code is organized.

Right, but I'm still too stupid to join the dots :-(

More concretely, I want to spin up an autobahn websocket client, have it 
connect, send a login message, confirm that worked, send a 'create' 
message, confirm that worked, and *then* let the rest of my code progress...

I'm surprised there don't appear to be any example of this floating 
around, and disappointed at the lack of examples of good tests for these 
things.

Chris




More information about the Twisted-Python mailing list