Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def worker(*args):
run_async_from_thread(sleep, *args)
return True
def worker(a, b):
assert threading.get_ident() != event_loop_thread_id
return run_async_from_thread(add, a, b)
def thread_worker():
nonlocal last_active
run_async_from_thread(sleep_event.set)
time.sleep(0.2)
last_active = 'thread'
run_async_from_thread(finish_event.set)
def _generator(self):
"""
Runs the websocket generator. This is used by calling next() over it.
"""
ws = WebSocket(self._url, agent=USER_AGENT)
websocket = persist(ws, ping_rate=0, poll=1, exit_event=self._cancelled)
self._ws = ws
for item in websocket:
# for some reason lomond doesn't exit the loop??
if self._cancelled.is_set():
break
anyio.run_async_from_thread(self._queue.put, item)
anyio.run_async_from_thread(self._queue.put, self._DONE)
def _generator(self):
"""
Runs the websocket generator. This is used by calling next() over it.
"""
ws = WebSocket(self._url, agent=USER_AGENT)
websocket = persist(ws, ping_rate=0, poll=1, exit_event=self._cancelled)
self._ws = ws
for item in websocket:
# for some reason lomond doesn't exit the loop??
if self._cancelled.is_set():
break
anyio.run_async_from_thread(self._queue.put, item)
anyio.run_async_from_thread(self._queue.put, self._DONE)