saltyrtc-server-python icon indicating copy to clipboard operation
saltyrtc-server-python copied to clipboard

Revise cancellation of futures

Open lgrahl opened this issue 7 years ago • 0 comments

Cancellation is propagated if not handled/shielded.

For example, when cancelling a Server.wait_closed, the handler tasks one is waiting for will be cancelled. We should carefully examine the public API and prevent futures from cancellation which shouldn't be cancelled.

Edit: This also affects the internal API. And coroutines are often moved into tasks, so we basically have to look at every yield from. An alternative to add tons of asyncio.shield is to mark a specific internal coroutine/task/future as don't cancel unless you really want to exit now. Candidates for this are, among others, ServerProtocol.handler and ServerProtocol.handle_client.

Edit 2: Wow, this issue sounds more scary than it actually is. Don't worry. The only critical operations affected here are enqueues into the task queue. But since the queue is unlimited, it will never block at the moment.

lgrahl avatar Aug 30 '18 15:08 lgrahl