Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Poller():
- def __init__(self, q, killswitch):
- self.q = q
- self.killswitch = killswitch
- self.path = conf.FIFO_PATH
- self.dir = conf.FIFO_DIRECTORY
- if not os.path.exists(self.dir):
- os.mkdir(self.dir)
- if not os.path.exists(self.path):
- new_file(self.path)
- self.fifo = os.open(self.path, os.O_RDONLY | os.O_NONBLOCK)
- self.poller = select.poll()
- self.poller.register(self.fifo, select.POLLIN)
- def listen(self):
- while not self.killswitch.isSet():
- p = self.poller.poll()
- msg = os.read(p[0][0], 50)
- if len(msg):
- ev = Event(msg, self.q)
- ev.signal()
Add Comment
Please, Sign In to add comment