[Twisted-Python] Re: 3 questions about async, threading and dynamic protocol selection

Nicola Larosa nico at tekNico.net
Wed Apr 4 08:43:54 EDT 2007

> littlesweetmelon at gmail.com wrote:
>> Q1: How to determine a function is 'blocking action' or not? Any
>> function needs CPU times. Indeed, a computational-intensive function
>> is blocking action. But how small/fast function can be classified as
>> non-blocking?

glyph at divmod.com wrote:
> You've basically answered your own question here.  A "blocking action" 
> is one where your users will not want to wait for it :).

A value typically used as a reference point, on a human time scale, is a
hundredth of a second, that is, 0.01s, that is, 10ms. If that's the maximum
processing time of each event, you may expect a rate of at least 100 events
per second, with a good overall event flow in the system, depending on the
system load.

>> Twist requires all user functions to be non-blocked. If reactor calls
>> a blocking function, what will happen? In my mind, reactor maintains a
>> command queue internally (just like windows message queue). The
>> blocking function only postpones the execution of other queued
>> functions, but it does not break the logic of the program. Is that
>> right?

Yes, that's right. The processing of subsequent events will be delayed, but
the program will still run correctly, *if* its correctness does not
depend on the timing of event processing.

Nicola Larosa - http://www.tekNico.net/

E-mail can be saved by your ISP or by the IT department
in your corporation. Gmail, for example, saves everything,
even if you delete it. -- Bruce Schneier, November 2006

More information about the Twisted-Python mailing list