开发者

Process() called from from Pylons creates a fork

开发者_C百科I'm trying to create a background process for some heavy calculations from the main Pylons process. Here's the code:

    p = Process(target = instance_process, \
                args = (instance_tuple.instance, parent_pipe, child_pipe,))
    p.start()

The process is created and started, but is seems to be a fork from the main process: it is listening to the same port and the whole application hangs up. What am I doing wrong?

Thanks in advance.


Process IS a fork. If you look through it's implementation you'll find that Process.start() calls a fork. It does NOT, however, call any of the exec variations to change the execution context.

Still, this may have nothing to do with listening on the same port (unless the parent process is multi-threaded). At which point is the program hanging? I know that when you try shutting down a python program without terminating the child process created through multiprocessing it will hang until the child process terminates. This might be caused if, for instance, you do not close the pipe between the processes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜