[Twisted-Python] PB waitingForAnswers KeyError

Bob Ippolito bob at redivi.com
Fri Jul 22 20:19:25 EDT 2005


On Jul 22, 2005, at 1:32 PM, William Waites wrote:

> On Fri, Jul 22, 2005 at 09:19:50AM -1000, Bob Ippolito wrote:
>
>>
>> I expect that you're using TwistedManager incorrectly.  There doesn't
>> appear to be anything wrong with the code you attached, but it also
>> doesn't do anything on its own.
>>
>
> I'm trying to put together a minimal example that is supposed to  
> work and
> doesn't.
>
> How the bit driven by calls works; the embedded Python creates a  
> thread
> and does something like:
>
>   d = routeServer.callRemote("lookup", "somesource", "somedest")
>   rset = manager.getDeferred(d)

That's your problem, you can't call ANY Twisted code from anything  
but the reactor thread (the one that called interleave), unless  
explicitly stated that it's allowed to do so (callFromThread, for  
example).

You've misunderstood what the example is trying to demonstrate, it is  
not a magical "invert twisted" box.  It demonstrates how you can  
create a simple ostensibly single-threaded application using Twisted  
that has a blocking interface on top of Deferreds.  It's similar to  
how you would use any of the networking code in the standard library,  
only that there's asynchronous goodness somewhere behind the scenes  
making everything tick.

-bob





More information about the Twisted-Python mailing list