Repository navigation
Allow overriding future-task compliance check in asyncio #91323
Description
Activity
Now asyncio.Task has a strict hardcoded check for futures processes on task's step.
Sometimes third-party library [1] wants to replace it with custom logic.
Currently it is impossible without implementing the full asyncio.Task replacement from scratch.
asyncio.Taskis a non-trivial highly optimized part of async, keeping a third-party version in sync with the reference implementation takes more time and effort than it should be.This issue proposes adding
Task._check_future(future)method that could be overridden in subclasses. The default C implementation uses a fast path that has no performance penalty.- https://github.com/aio-libs/aioloop-proxy implements nested loop proxies that are very useful for writing tests. A proxy can work in parallel with ancestors but checks all own acquired resources cleanup on
the proxy closing.
- https://github.com/aio-libs/aioloop-proxy implements nested loop proxies that are very useful for writing tests. A proxy can work in parallel with ancestors but checks all own acquired resources cleanup on
Sorry, I don't like the committed change and I think it should be reverted.
Futures and Tasks have a documented
get_loop()method which simply should be called by Task machinery, without the need to expose (and document) private methods.This patch isn't needed to support the aioloop-proxy use case, you can use an interceptor coroutine to pass the check instead:
aio-libs/aioloop-proxy@a655652
this way aioloop proxy works with asyncio.Task CTask PyTask and in addition custom set_task_factory Tasks
Reacted by Łukasz Langa- added a commit that references this issue
on Aug 4, 2022 - added a commit that references this issue
on Aug 4, 2022 Closing as the PR was reverted and it is not needed #91323 (comment).
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: