Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire and forget task does not hold a strong reference #486

Open
bdraco opened this issue Apr 30, 2024 · 4 comments
Open

Fire and forget task does not hold a strong reference #486

bdraco opened this issue Apr 30, 2024 · 4 comments
Labels
no-stale This issue or PR is exempted from the stale bot python Pull requests that update Python code

Comments

@bdraco
Copy link

bdraco commented Apr 30, 2024

self._timeout, lambda: asyncio.create_task(self.on_expire())

https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task

Important 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. For reliable “fire-and-forget” background tasks, gather them in a collection:

@issuelabeler issuelabeler bot added the python Pull requests that update Python code label Apr 30, 2024
Copy link

There hasn't been any activity on this issue recently, so it has been marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment.
This issue will be closed if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for some time label May 31, 2024
@bdraco
Copy link
Author

bdraco commented May 31, 2024

Keep alive

@bachya
Copy link
Owner

bachya commented May 31, 2024

Thanks, @bdraco—been slammed at work, so haven't had a chance to look at this, but will soon.

@bachya bachya added no-stale This issue or PR is exempted from the stale bot and removed stale There has not been activity on this issue or PR for some time labels May 31, 2024
@bdraco
Copy link
Author

bdraco commented May 31, 2024

No worries. This one is low priority

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-stale This issue or PR is exempted from the stale bot python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

2 participants