[Twisted-Python] First try at thread-safe FileDescriptor

Moshe Zadka m at moshez.org
Fri Aug 10 15:04:20 EDT 2001

On Fri, 10 Aug 2001, Itamar Shtull-Trauring <itamar at zoteca.com> wrote:

>  > Please, please, use either diff -u or diff -c. Plain diff is simply
>  > unreadable
> D'oh. I must've never set it up on my laptop.

I am not at all certain this is thread safe....

Let us say one thread calls .write and another .doWrite
Then if the .write thread modifies the unsentChunks after the
.doWrite finished summing up the chunks but before it does the
self.unsent =  then whatever it has written will be lost, no?

Personally, I think you should write a ThreadSafe descriptor
which uses the thread-safe Queue class to Queue data to write in .write
and takes out stuff from the Queue in .doWrite until it had its fill.
Moshe Zadka - http://moshez.geek
(if you're not cool, http://moshez.org is still working)

More information about the Twisted-Python mailing list