2 ms·
Let me break it down for you: Suppose I run asyncio.start_server() and I want it to run forever. What am I supposed to asyncio.gather()) on without making stuf
by m3047 4y ago
Let me break it down for you:
Suppose I run asyncio.start_server() and I want it to run forever. What am I supposed to asyncio.gather()) on without making stuff up?
[Edit] Production code or it didn't happen.
- m3047 4y agoGiven 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.