Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import os
  2. import time
  3. print("hello")
  4.  
  5. #import subprocess
  6. #MyOut = subprocess.Popen(['gnome-terminal','--command=python3 test2.py'],
  7. # stdout=subprocess.PIPE,
  8. # stderr=subprocess.STDOUT)
  9. #print(MyOut.pid)
  10. #time.sleep(4)
  11. #stdout,stderr = MyOut.communicate()
  12. #print(stdout)
  13. #print(stderr)
  14.  
  15.  
  16. import os, time
  17.  
  18. pipe_path = "/tmp/mypipe"
  19. if not os.path.exists(pipe_path):
  20. os.mkfifo(pipe_path)
  21. # Open the fifo. We need to open in non-blocking mode or it will stalls until
  22. # someone opens it for writting
  23. pipe_fd = os.open(pipe_path, os.O_RDONLY | os.O_NONBLOCK)
  24. with os.fdopen(pipe_fd) as pipe:
  25. while True:
  26. message = pipe.read()
  27. if message:
  28. print("Received: '%s'" % message)
  29. print("Doing other stuff")
  30. time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement