Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Given this:

    server = await asyncio.start_server(
            context.handle_requests, str(config.host), config.port, limit=MAX_READ_SIZE
        )
as stated, you can't use gather(). There are sleight of hand "coincidences", such as waiting on a watchdog which runs forever.

I stumbled on this as something that works:

    useless_lock = asyncio.Lock()
    while True:
        await useless_lock.acquire()
Which demonstrates that the following is, ahem, sleight of hand:

    async with server:
        await server.serve_forever()
although supposedly it guarantees some cleanup which I don't care about. Both options respond identically (at least with 3.11.0) to ^C.

I reiterate that serve_forever() is not in 3.6.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: