[Twisted-Python] Re: Twisted-Python Digest, Vol 45, Issue 18

glyph at divmod.com glyph at divmod.com
Sun Dec 16 01:41:57 EST 2007

On 03:37 am, josef.robert.novak at gmail.com wrote:
>How can I obtain the pid of a new deferToThread object?  If I can 
>obtain it,
>then I can just keep a persistent dictionary containing all the running
>compute-intensive processes, and unregister each one in a callback 
>after it
>finishes up.  Then, every time a new call comes in, I check my 
>pid dictionary/list,
>for pid in pid_list:
>  os.kill(pid, signal.SIGSTOP)

If this even does anything at all, it will effectively just crash or 
wedge python.  Plus, on many platforms threads don't have PIDs, because 
they're not processes, they're threads.

You need to use subprocesses to split up your long-running tasks, not 
threads.  Have a look at the documentation for reactor.spawnProcess: 

More information about the Twisted-Python mailing list