Twisted: 1 thread in the reactor pattern

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sat Sep 26 16:22:31 CEST 2009


On 25 Sep, 05:25 am, jacopo.pecci at gmail.com wrote:
>On Sep 24, 7:54 pm, exar... at twistedmatrix.com wrote:
>>On 07:10 am, jacopo.pe... at gmail.com wrote:
>> >On Sep 23, 5:57 pm, exar... at twistedmatrix.com wrote:
>> >[snip]
>[snip]
>>
>>If you have a function that takes 5 minutes to run, then you're 
>>blocking
>>the reactor thread for 5 minutes and no other events are serviced 
>>until
>>the function finishes running.
>>
>>You have to avoid blocking the reactor thread if you want other events
>>to continue to be serviced.  There are various strategies for avoiding
>>blocking.  Different strategies are appropriate for different kinds of
>>blocking code.
>>
>>Jean-Paul- Hide quoted text -
>>
>>- Show quoted text -
>
>Even if the server is engaged in a 5 minutes processing other arriving
>requests of callRemote() are queued and  Deferreds are returned
>immediately.

Nope, they're not.  The bytes representing the new requests sit in the 
socket buffer until the function finishes processing and the reactor 
gets an opportunity to read them.
>
>Could you suggest me any doc to better understand?

If you haven't read 
http://twistedmatrix.com/projects/core/documentation/howto/async.html 
yet, that may be a good idea.

Jean-Paul



More information about the Python-list mailing list