path = '/tmp/pipe'
chunk_size = 8192
fd = os.open(path, os.O_RDONLY | os.O_NONBLOCK)
def do_something():
pass
def check_timer():
pass
def do_another():
pass
while True:
try:
output = os.read(fd, chunk_size)
except (OSError, IOError):
print "Чето поломалось"
if not output:
print 'pipe закрылся'
else:
print "Мои данные: ", output
do_something()
if check_timer():
do_another()