How to use the aiomisc.threaded function in aiomisc

To help you get started, we’ve selected a few aiomisc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiokitchen / aiomisc / tests / test_entrypoint.py View on Github external
    @aiomisc.threaded
    def http_client():
        conn = http.client.HTTPConnection(
            host='127.0.0.1',
            port=aiomisc_unused_port,
            timeout=1
        )

        conn.request('GET', '/')
        response = conn.getresponse()
        return response.code
github aiokitchen / aiomisc / tests / test_thread_pool.py View on Github external
@pytest.fixture(params=(aiomisc.threaded, aiomisc.threaded_separate))
def threaded_decorator(request, executor: aiomisc.ThreadPoolExecutor):
    assert executor
    return request.param
github aiokitchen / aiomisc / tests / test_entrypoint.py View on Github external
    @aiomisc.threaded
    def writer():
        with ExitStack() as stack:
            sock = stack.enter_context(
                socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
            )

            ssock = stack.enter_context(ssl_client_context.wrap_socket(
                sock, server_hostname='localhost'
            ))

            ssock.connect(('127.0.0.1', aiomisc_unused_port))
            ssock.send(b'hello server\n')
github aiokitchen / aiomisc / tests / test_thread_pool.py View on Github external
async def test_cancel(executor, loop, timer):
    sleep = aiomisc.threaded(time.sleep)

    async with timeout(2):
        with timer(1, dispersion=2):
            tasks = [loop.create_task(sleep(1)) for _ in range(1000)]

            await asyncio.sleep(1)

            for task in tasks:
                task.cancel()

    executor.shutdown(wait=True)
github aiokitchen / aiomisc / tests / test_thread_pool.py View on Github external
    @aiomisc.threaded
    def arange(*args):
        return (yield from range(*args))