[Twisted-Python] Twistd thread problem

Christopher Armstrong radeex at gmail.com
Sat May 21 04:29:47 EDT 2005


On 5/21/05, Gangadhar NPK <npk.gangadhar at gmail.com> wrote:
> Orbitz, can you please state why do you think it is not a good idea to
> use a worker thread. If the OP wanted to create a high volume SMTP
> proxy with each worker thread handling every invocation from the smtp
> client (smtplib in this case), then don't you think this can scale
> better than a single thread, wherein the remaining clients are waiting
> in the wait queue (if something like that exists, am not sure about
> that) while one smtp data transfer is being done.
> Also, if the OP chose to use a master-servant model wherein the master
> thread keeps a tab on each of the worker thread to see the status and
> (may be) notify the user (via a ui) of the status, the thread model
> will work ?

There's no reason to use a thread because all network I/O is
non-blocking in Twisted. There is no "wait queue"; as soon as you
write data to the transport, it either gets sent immediately or
buffered and execution continues on. There's no performance reason to
use a thread and it just complicates things when you can use the
non-blocking SMTP code.

-- 
  Twisted   |  Christopher Armstrong: International Man of Twistery
   Radix    |    -- http://radix.twistedmatrix.com
            |  Release Manager, Twisted Project
  \\\V///   |    -- http://twistedmatrix.com
   |o O|    |  Founding Member, Hobart Hacking Society
w----v----w-+    -- http://hackingsociety.org/chapters/hash




More information about the Twisted-Python mailing list