Exemple #1
0
 def async_watch(self, loop=None):
     _LOGGER.debug("Start watching...")  # pragma: no cover
     if loop is None:
         loop = self._loop
     _LOGGER.debug("loop: %s", loop)
     while self._running:
         if self.initialized:
             _LOGGER.debug("Scanning...")  # pragma: no cover
             yield from self.async_scan()
             _LOGGER.debug("Sleep...")  # pragma: no cover
             start_time = self._loop.time()
             while self._loop.time() <= (
                     start_time + self._scan_interval) and self._running:
                 yield from asyncio.sleep(.3, loop=loop)
         else:
             _LOGGER.warning("Not initialized. Waiting for init.")
             yield from asyncio.sleep(1, loop=loop)
     _LOGGER.info("No watching anymore")
Exemple #2
0
 def __init__(self,
              adapter: AbstractCecAdapter,
              scan_interval=DEFAULT_SCAN_INTERVAL,
              loop=None):
     self._running = False
     self._device_status = dict()
     self._managed_loop = loop is None
     if self._managed_loop:
         self._loop = asyncio.new_event_loop()
     else:
         _LOGGER.warning("Be aware! Network is using shared event loop!")
         self._loop = loop
     self._adapter = adapter
     self._adapter.set_event_loop(self._loop)
     self._scan_delay = DEFAULT_SCAN_DELAY
     self._scan_interval = scan_interval
     self._command_queue = Queue()
     self._devices = dict()
     self._command_callback = None
     self._device_added_callback = None
     self._initialized_callback = None
     self._device_removed_callback = None