简体   繁体   中英

Python Keep Named Pipe Open

In bash, a named pipe can be kept open with cat > mypipe . How can this be done in python? This is what I have so far:

import subprocess
import os

if not os.path.exists("/tmp/mypipe"):
    os.mkfifo("/tmp/mypipe")
import os
import subprocess

path = '/tmp/mypipe'
if not os.path.exists(path):
    os.mkfifo(path)

with open(path, 'w') as f:
    subprocess.call(['cat'], stdout=f)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM