Python 的多进程 fork,python进程fork,using_fork.p
Python 的多进程 fork,python进程fork,using_fork.p
using_fork.py:
#!/usr/bin/python# Filename:using_fork.pyimport os, sysprint "I'm going to fork now"r, w = os.pipe()pid = os.fork()if pid: # parent os.close(w) r = os.fdopen(r) print "parent: reading" txt = r.read() os.waitpid(pid, 0)else: # child os.close(r) w = os.fdopen(w, 'w') print "child:writing" w.write("here's some text from the child") w.close() print "child:closing" sys.exit(0)
执行结果:
jobin@jobin-desktop:~/work/python/fork$ python using_fork.pyI'm going to fork nowparent: readingchild:writingchild:closing
相关内容
- Python 多进程实现分析,python进程实现,Python Stand
- Python连接使用redis,python连接redis,需要下载 redis-p
- 使用python获得网站的alexa排名,pythonalexa,如下脚本,使
- python获得Google PageRank(PR)的脚本,pythonpagerank,如下p
- python 实现命令行的进度条,python进度条,如下代码片段
- python实现switch语句,pythonswitch语句,python本身没有sw
- python实现对象的深拷贝,python实现拷贝,python对象的深拷
- python的super关键字使用示例,pythonsuper关键字,super在单继
- os.rename()导致WindowsError: [Error 32]问题的解决,,刚接触
- Python实现通用的unix/linux守护进程,python守护进程,下面
评论关闭