[Twisted-Python] Threading WIth Twisted
Glyph Lefkowitz
glyph at twistedmatrix.com
Wed Oct 23 08:25:01 MDT 2002
On Wed, 23 Oct 2002 13:32:21 +0100, John Abel <john.abel at pa.press.net> wrote:
> So that Twisted doesn't come to a standstill whilst compress a large file, I
> made the compress function run in a seperate thread.
> This thread, attempts to write to the same file as the initial thread.
Why are two separate compression attempts writing to the same file? Shouldn't
the file be named something along the lines of twistd.{1,2,3,4,...}.log.gz?
> 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?
Yes, there is a way to do this. Twisted provides utilities to have threads
interact with its mainloop, but it does not provide a full threading model:
that's Python's job. Take a look at the "threading" and "Queue" modules in the
standard library.
> This only ever occurs, when the log rotation is set to occur very frequently,
> (i.e. every couple of seconds, or every 100 bytes), but I'd rather fix it,
> than impose limits on the frequency of log rotation.
Yeah, and it's because of problems like this that we try to steer clear of
threads in general in Twisted ;-). Have you considered the block-at-a-time
approach that radix suggested? That way you wouldn't need to run threads at
all...
--
| <`'> | Glyph Lefkowitz: Travelling 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: </pipermail/twisted-python/attachments/20021023/dbcc504c/attachment.sig>
More information about the Twisted-Python
mailing list