Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Detect tasks that could disappear mid-execution #5

Open
alicederyn opened this issue Nov 1, 2022 · 3 comments
Open

Detect tasks that could disappear mid-execution #5

alicederyn opened this issue Nov 1, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@alicederyn
Copy link

The docs for asyncio.create_task say:

Save a reference to the result of this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn’t referenced elsewhere may get garbage collected at any time, even before it’s done.

It's really easy to miss this and try to fire-and-forget. It would be great if flake8-async detected this.

@cooperlees cooperlees added enhancement New feature or request help wanted Extra attention is needed labels Nov 1, 2022
@cooperlees
Copy link
Collaborator

+1 on this. Would be smart we recommend people keep variables around until tasks complete etc. and link to these docs.

As always, please update README + unittests.

@Zac-HD
Copy link
Owner

Zac-HD commented Nov 6, 2022

Just a note that asyncio-specific checks should only emit warnings if asyncio is imported into the code we're linting.

(also applies to trio or curio fwiw, though I pretty quickly started a separate flake8-trio project for the former)

@jakkdl
Copy link
Contributor

jakkdl commented Feb 16, 2024

@Zac-HD this one might make sense to add to flake8-trio, is trivial to implement, and is supported by ruff (and would make more sense there to be moved under ASYNCxxx than as RUF006).

Checked the other two open issues, and they're already covered in flake8-trio.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants