[Twisted-Python] shared list in factory, mutexes?
itamar at itamarst.org
Mon Apr 14 09:27:38 EDT 2008
On Mon, 2008-04-14 at 12:35 +0200, Gabriel Rossetti wrote:
> I'm wondering if maybe I'm misunderstanding something here, when several
> messages arrive, what happens, are they processed in parallel, are they
> put in a queue and processes sequentially?
Sequentially. Twisted does not expose use of threads to user-level
APIs... and Twisted APIs are not thread-safe, other than
> If I receive a message, do
> some heavy processing/io/potentially blocking code in a thread using
> twisted's threading module, and before it's done, I get another
> connection + message that needs the same thing to be done, what
reactor.callInThread (and therefore deferToThread) are built on top of a
thread-safe Queue. Just make sure your scheduled tasks are not calling
back into Twisted but are rather self-contained units of work.
More information about the Twisted-Python