Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def listen_to_watcher(event_found, conn, future):
logging.info("Starting to listen for the watcher.")
all_watcher = watcher.AllWatcher()
all_watcher.connect(conn)
for _ in until_timeout(120):
logging.info("Listening for events...")
change = await all_watcher.Next()
for delta in change.deltas:
logging.info("Event received: {}".format(str(delta.deltas)))
if event_found(delta.deltas) is True:
await all_watcher.Stop()
await conn.close()
logging.info("Event found: {}".format(str(delta.deltas)))
future.set_result(True)
return
await all_watcher.Stop()
await conn.close()
logging.warning("Event not found.")