[Twisted-Python] thoughts on a reactor feature

Glyph Lefkowitz glyph at twistedmatrix.com
Mon Sep 23 21:07:47 EDT 2002

On Mon, 23 Sep 2002 12:54:22 -0600, Bruce Mitchener <bruce at cubik.org> wrote:

> One would be have an interface to POSIX clocks and track the amount of 
> time spent between calls out of reactor.run() and report anything that 
> takes over a specified threshold of time to execute.

If I understand your proposal correctly, I think this could be implemented
quite simply by writing a Python wrapper around the reactor, that would wrap
each protocol and protocol factory being passed to it in something that would
catch events and time their execution.  This should work for just about any
reactor.  With a few extra features, it might even be good for measuring their
differences.  Would you need a wrapper around POSIX clocks more robust than

(I think this could also compare time.clock() to time.time() to see if
potentially blocking calls were being made.)

> Another is to implement some sort of stack trace sampling where you
> periodically take a stack trace when a utility program is running and you've
> noted periods of long latency.

This I don't know how to do; possibly it's doable with Python's
debugger/profiler hooks?  I'm not quite clear on how you do the "noting" -- is
this a message that the user sends to Twisted or is it something that the
profiler performs some heuristic to get?

 |    <`'>    |  Glyph Lefkowitz: Traveling Sorcerer   |
 |   < _/ >   |  Lead Developer,  the Twisted project  |
 |  < ___/ >  |      http://www.twistedmatrix.com      |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020923/8604d943/attachment.pgp 

More information about the Twisted-Python mailing list