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 test_receive_signals():
async with open_signal_receiver(signal.SIGUSR1, signal.SIGUSR2) as sigiter:
await run_sync_in_worker_thread(os.kill, os.getpid(), signal.SIGUSR1)
await run_sync_in_worker_thread(os.kill, os.getpid(), signal.SIGUSR2)
assert await sigiter.__anext__() == signal.SIGUSR1
assert await sigiter.__anext__() == signal.SIGUSR2
async def test_run_in_thread_exception():
def thread_worker():
raise ValueError('foo')
with pytest.raises(ValueError) as exc:
await run_sync_in_worker_thread(thread_worker)
exc.match('^foo$')
async def task_worker():
await run_sync_in_worker_thread(thread_worker, limiter=limiter)
async def flush(self) -> None:
return await anyio.run_sync_in_worker_thread(self._fp.flush)
async def tell(self) -> int:
return await anyio.run_sync_in_worker_thread(self._fp.tell)
async def readinto1(self, b: Union[bytes, memoryview]) -> bytes:
return await anyio.run_sync_in_worker_thread(self._fp.readinto1, b)
async def write(self, b: bytes) -> None:
return await anyio.run_sync_in_worker_thread(self._fp.write, b)
async def truncate(self, size: Optional[int] = None) -> int:
return await anyio.run_sync_in_worker_thread(self._fp.truncate, size)
async def aclose(self) -> None:
return await anyio.run_sync_in_worker_thread(self._fp.close)
async def writelines(self, lines: bytes) -> None:
return await anyio.run_sync_in_worker_thread(self._fp.writelines, lines)