Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def thread_fn(self):
while True:
try:
request = self._portal.run(self._receive_from_trio.receive)
except (Cancelled, RunFinishedError):
break
except trio.EndOfChannel:
with suppress(Cancelled, RunFinishedError):
self._portal.run(self._send_to_trio.aclose)
break
response = outcome.capture(request)
self._portal.run(self._send_to_trio.send, response)
def thread_fn(self):
while True:
fut = asyncio.run_coroutine_threadsafe(
self._request_queue.get(), self._loop)
try:
request = fut.result()
except CancelledError:
continue
if request is not _STOP:
response = outcome.capture(request)
fut = asyncio.run_coroutine_threadsafe(
self._response_queue.put(response), self._loop)
fut.result()
else:
fut = asyncio.run_coroutine_threadsafe(
self._response_queue.put(None), self._loop)
fut.result()
break