[Twisted-Python] Advise for heavy concurrency

Alec Matusis matusis at yahoo.com
Sat Dec 1 20:40:28 MST 2007


> > You cannot call any Twisted functions from a thread, with the
> > exception
>                                         ^^^^^^^^^^^^^ Er, I guess I
> should have worded this more carefully. What I meant is: you cannot
> call any Twisted functions from a different thread to the one the
> reactor is running in, which includes any thread created with
> deferToThread.
> 
> > of callFromThread; so this would probably be pretty pointless.


I am not sure I understood this: suppose my message sending loop simply 
loops over client protocol instances and calls 
transport.write(some_message)  

Why cannot I call this loop in a thread from the main reactor loop 
to have it non-blocking in case this sending loop is giant (over 1000s of clients)?
I do not care when this sending loop is finished, I just do not want this to slow down 
the main reactor loop.

With 50 clients this is obviously unnecessary.

> -----Original Message-----
> From: twisted-python-bounces at twistedmatrix.com [mailto:twisted-python-
> bounces at twistedmatrix.com] On Behalf Of Tristan Seligmann
> Sent: Saturday, December 01, 2007 6:57 PM
> To: twisted-python at twistedmatrix.com
> Subject: Re: [Twisted-Python] Advise for heavy concurrency
> 
> * Tristan Seligmann <mithrandi at mithrandi.za.net> [2007-12-02 04:50:44
> +0200]:
> 
> > * Atilla <theatilla at gmail.com> [2007-12-02 00:37:47 +0100]:
> >
> > > When it comes to deferToThread - is that actually going to be of
> any
> > > use? Do I get an advantage of running the "send" loop in a seperate
> > > thread? What if, say, I never had to send more than 10-50 messages,
> > > so
> >
> > You cannot call any Twisted functions from a thread, with the
> > exception
>                                         ^^^^^^^^^^^^^ Er, I guess I
> should have worded this more carefully. What I meant is: you cannot
> call any Twisted functions from a different thread to the one the
> reactor is running in, which includes any thread created with
> deferToThread.
> 
> > of callFromThread; so this would probably be pretty pointless.
> --
> mithrandi, i Ainil en-Balandor, a faer Ambar





More information about the Twisted-Python mailing list