[Twisted-Python] What's twistd doing on Windows?

Andrew Bennetts andrew-twisted at puzzling.org
Tue Apr 8 09:42:31 EDT 2003


On Thu, Apr 03, 2003 at 06:31:32PM -0500, Bob Ippolito wrote:
> On Thursday, Apr 3, 2003, at 18:16 America/New_York, Christopher 
> Armstrong wrote:
> 
> >On Thu, Apr 03, 2003 at 05:16:02PM -0500, Alan McIntyre wrote:
> >>I did notice something that I'm curious about: I've been running two
> >>Twisted web instances, one on a Win2k machine (1.4GHz P4, Python 2.2.2)
> >>and one on a Debian machine (266MHz PII, Python 2.1.3) for a few days
> >>now, and the Windows instance has accumulated almost an hour of CPU time
> >>wherease the Debian instance has only used 2 seconds.  What's the Win32
> >>instance doing while it's idle? (It's not a big deal, I'm just curious)
> >
> >My first guess would be that the system calls involved (e.g., select)
> >are more expensive than on linux, but that's just a wild guess. I
> >doubt profiling would be much help, but maybe you (or someone) could
> >write a simple test that just recorded the time it takes to run an
> >immediately-returning select() a few thousand times.
> 
> IIRC, the Twisted select reactor has a "background process" that gets 
> triggered once a second or so when running on windows just to break the 
> select() call (I don't believe it actually does anything).  I believe 
> this is because processes in windows don't respond to signals (like 
> ctrl-c, for example) during a select() call, so this 
> convenience/workaround was put into the codebase.

Unless the implementation has changed significantly since I last looked at
it, this is the correct answer.  The select call under win32 times out every
second so that Ctrl-C/Ctrl-Break and other things (like stopping a Twisted
program running as a WinNT service) happen in a timely fashion, rather than
relying on network activity to wake it up.

-Andrew.





More information about the Twisted-Python mailing list