[Twisted-Python] Question about processes in python

Gabriel Rossetti gabriel.rossetti at arimaz.com
Mon Apr 12 08:40:35 EDT 2010


Reza Lotun wrote:
> Hi,
>
>   
>> I'd like to run a python function in a new process, like python 2.6's
>> multiprocessing does. I wanted to use ProcessProtocol, but it seems to
>> only work for executing executables and interacting with them using
>> stdin/stdout/other fds. Is there a way of running a python piece of code
>> in a new process?
>>     
>
> Well, the only way to run Python code is to run the Python interpreter
> in a process and feed it the python code you want to run (using the -c
> option).
>
> Cheers,
> Reza
>
>   
Hi Reza,

yes, I'd thought of that, but I can't get the function's code, I tried 
the inspect module but
it only works of the code is written to disk; I'd rather not have to 
first write the code to disk just to be able to turn it into a string 
and feed it to python -c. Any ideas on how I could do this?

Thanks,
Gabriel



More information about the Twisted-Python mailing list