[Twisted-Python] Threading WIth Twisted

Itamar Shtull-Trauring twisted at itamarst.org
Wed Oct 23 08:21:54 MDT 2002


On Wed, 23 Oct 2002 13:32:21 +0100
John Abel <john.abel at pa.press.net> wrote:

> I am in the process of adding the option to compress logfiles, to 
> twisted.python.logfile.  So that Twisted doesn't come to a standstill 
> whilst compress a large file, I made the compress function run in a 
> seperate thread.  However, if the file takes longer than a couple of 
> seconds to compress, and rotate is called again, another thread is 
> launched.  This thread, attempts to write to the same file as the 
> initial thread.  I've had a look at the code, but I can't seem to find
> a provision within Twisted, to queue the threads.  Is there a way to
> do this, or, should I be looking at something else?

Set a flag "compressionInProgress".

If it is set, just remember you need to compress. When the thread
finishes it should call a callback (via reactor.callFromThread, or use
threads.deferToThread) and that callback will start up a new
compression.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python, Twisted, Zope and Java consulting




More information about the Twisted-Python mailing list