This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Allow overriding future-task compliance check in asyncio
Type: Stage: resolved
Components: asyncio Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, yselivanov
Priority: normal Keywords: patch

Created on 2022-03-30 15:34 by asvetlov, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 32197 merged asvetlov, 2022-03-30 15:36
Messages (3)
msg416374 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-30 15:34
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.Task` is 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.

1. 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.
msg416467 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-04-01 01:25
New changeset d4bb38f82bf18b00db3129031ce4969b6f0caab9 by Andrew Svetlov in branch 'main':
bpo-47167: Allow overriding a future compliance check in asyncio.Task (GH-32197)
msg416468 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2022-04-01 02:14
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.
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91323
2022-04-01 02:14:55yselivanovsetstatus: closed -> open
resolution: fixed ->
messages: + msg416468
2022-04-01 01:25:32asvetlovsetmessages: + msg416467
2022-04-01 01:25:31asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-30 15:36:59asvetlovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request30273
2022-03-30 15:34:50asvetlovcreate