Example #1
0
 def stop_door_switch_watcher(self, loop: asyncio.AbstractEventLoop):
     try:
         door_fd = self.lines['window_door_sw'].event_get_fd()
         loop.remove_reader(door_fd)
     except Exception:
         MODULE_LOG.exception(
             "Failed to remove window door switch fd reader")
Example #2
0
    def remove_listener(self, eventloop: asyncio.AbstractEventLoop) -> None:
        """Remove the listener from the given event loop

        :param eventloop:
            The eventloop that had been setup for listening.
        """
        logger.debug("Removing io watch")
        eventloop.remove_reader(self.fd)
        self.qtile = None
        self.conn.finalize()
Example #3
0
 async def _watch(self, loop: AbstractEventLoop):
     future = asyncio.Future()
     loop.add_reader(self.fd, future.set_result, None)
     future.add_done_callback(lambda _: loop.remove_reader(self.fd))
     await future
Example #4
0
async def wait_for_reader(fd: Union[int, io.BufferedReader], loop: asyncio.AbstractEventLoop) -> None:
    f: asyncio.Future = asyncio.Future()
    loop.add_reader(fd, f.set_result, None)
    f.add_done_callback(lambda f: loop.remove_reader(fd))
    await f