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