gh-97696: asyncio eager tasks factory by itamaro · Pull Request #102853 · python/cpython (original) (raw)
The proposal at the start of this thread suggested a new method or parameter for eager start. Is there a link to any discussion on why this changed? Are there plans to do something like that in future (or just to make it the default, and remove the old behaviour)?
I'm thinking about this from a library side. Changing the global task factory is inappropriate for a library to do, but we still have certain tasks that would strongly benefit from eager execution (I also wonder if a user enabling this globally could end up breaking a library that wasn't expecting eager tasks...).
So, some way to execute individual tasks eagerly would be useful (unless it simply becomes the default behaviour). We currently instantiate Task(eager_start=True)
directly, though the docs seem to strongly discourage this. Adding an eager_start
to asyncio.create_task()
, or maybe some way to temporarily change task factories (with eager_task_factory:
) would be ideal.