[Twisted-Python] One big smile ...

Thomas Weholt 2002 at weholt.org
Fri Jul 11 20:05:16 EDT 2003

I implemented a small newsfetching webserver today. At first I used some
blocking code at startup and then reactor.callLater(some_intervall,
sameBlockingMethod) to call it later and refresh the content later. It
processed about 8-10 RSS/RDF feeds and then handed my server back to me so I
could see the output. I was quite happy about the result. Just for fun I
tried to do the blocking code in a thread instead, - with mixed results.
Read some more docs. And did a deferToThread for each call to the blocking
method. Added a callback-method that parsed the results. A bit more hacking
and ...then .. suddenly ... it was just .... so fast. No hogging the server
at startup, all content fetched,, *much* faster than before. Everything
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

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

If I just solve the drunken attribute update process going on in my server
this will be a real break-thru for me Twisted-wise.

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


More information about the Twisted-Python mailing list