[Twisted-web] Deferred fun

Paul G paul-lists at perforge.com
Mon Jan 16 19:46:31 MST 2006

----- Original Message ----- 
From: "James R. Saker Jr." <cso at netcenturion.biz>
To: <twisted-web at twistedmatrix.com>
Sent: Monday, January 16, 2006 8:56 PM
Subject: [Twisted-web] Deferred fun

--- snip ---

you do not understand deferreds. a deferred is a means to register success 
and error handlers for an asynchronous operation. it is *not* a means to 
asynchronously invoke an operation, as you seem to think with 
"d.addCallback(self.handleScan(type, ip, detectOS, timing))". moreover, the 
'start a blocking program with popen' is, of course, a *blocking* operation 
and using twisted/deferreds/a rabbit foot is not going to make it 
asynchronous automagically. i suggest you read the excellent introductory 
documentation on twistedmatrix.com.

hints on how to make this work:

call handleScan with tiwsted.internet.threads.deferToThread(). this gives 
you a deferred; add a callback to this deferred which returns the result to 
your xmlrpc client.

also, this should be on the main twisted-l, not on twisted-web.


More information about the Twisted-web mailing list