[issue46843] PersistentTaskGroup API

Joongi Kim report at bugs.python.org
Fri Feb 25 02:03:06 EST 2022


Joongi Kim <me at daybreaker.info> added the comment:

Anoter case:

https://github.com/lablup/backend.ai-manager/pull/533
https://github.com/lablup/backend.ai-agent/pull/341

When shutting down the application, I'd like to explicitly cancel the shielded tasks, while keep them shielded before shutdown.

So I inserted `ptaskgroup.create_task()` inside `asyncio.shield()`, so that the tasks are not cancelled upon the cancellation of their callers but they get cancelled when the server shuts down.

This pattern is conveniently implemented with PersistentTaskGroup.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46843>
_______________________________________


More information about the Python-bugs-list mailing list