How do you share data between a parent and forked child process in Python?

后端 未结 5 2004
北恋
北恋 2020-12-10 13:23

I\'m pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there\'s a better way, I\'d be grateful to find out. Code snippets are v

5条回答
  •  春和景丽
    2020-12-10 13:57

    This is pretty much Python-independent! It's a classic example of Unix interprocess communication. One good option is to use popen() to open a pipe between the parent and child processes, and pass data/messages back and forth along the pipe.

    Take a look at the subprocess module, which can set up the necessary pipes automatically while spawning child processes.

提交回复
热议问题