python-fifo管道文件通信


 1 #!/usr/bin/python
 2 #coding=utf-8
 3 import os,sys,multiprocessing,time
 4 try:
 5     os.mkfifo('file')
 6 except :pass
 7 
 8 
 9 def read():
10     try:
11         os.mkfifo('file1')
12     except:pass
13     f=open('file1')
14     while 1:
15         str=f.readline()
16         print str
17         sys.stdout.flush()
18 m=multiprocessing.Process(target=read)
19 m.start()
20 
21 
22 f1=open('file','w')
23 while 1:
24     str=sys.stdin.readline()
25     f1.write(str)
26     f1.flush()
 1 #!/usr/bin/python
 2 #coding=utf-8
 3 import os,sys,multiprocessing,time
 4 try:
 5     os.mkfifo('file1')
 6 except :pass
 7 
 8 
 9 def read():
10     try:
11         os.mkfifo('file')
12     except:pass
13     f=open('file')
14     while 1:
15         str=f.readline()
16         print str
17         sys.stdout.flush()
18 m=multiprocessing.Process(target=read)
19 m.start()
20 
21 
22 f1=open('file1','w')
23 while 1:
24     str=sys.stdin.readline()
25     f1.write(str)
26     f1.flush()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM