[Twisted-Python] One big smile ...

Andrew Bennetts andrew-twisted at puzzling.org
Fri Jul 11 20:23:41 EDT 2003

On Sat, Jul 12, 2003 at 02:05:16AM +0200, Thomas Weholt wrote:
> seemed great. I had finally got the grip on threads and deferred. But
> something was wrong with my data. Some data were in the wrong lists etc. so
> I guess I need some mutex-locking or something. This is were you guys come
> in. Do I need to aquire a lock to avoid updating wrong parts of my
> datastructure?
> In the docs it says:
> "This will make certain parts of Twisted thread-safe so you can use them
> safely. However, note that most parts of Twisted are not thread-safe."
> What parts are still not thread-safe? My datastructures? They don't seem
> thread-safe.

In general, unless something in Twisted says it is thread-safe, it's not
thread-safe.  So, unless you are very sure about what you're doing, make
sure your threads don't share data with any other threads, including the
main-loop.  If they must share data, then use reactor.callFromThread -- a
thread can safely use callFromThread to call a function in the main
event-loop thread.

> Anyway, I still have a HUGE smile on my face.

Woo!  :)


More information about the Twisted-Python mailing list