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

Save strong reference to create_task #513

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Save strong reference to create_task #513

merged 2 commits into from
Feb 27, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Feb 27, 2024

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:

> 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:
@bdraco bdraco marked this pull request as ready for review February 27, 2024 21:50
Copy link
Collaborator

@bieniu bieniu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 👍

@bdraco
Copy link
Member Author

bdraco commented Feb 27, 2024

thanks

@bdraco bdraco merged commit 1978474 into main Feb 27, 2024
3 checks passed
@bdraco bdraco deleted the save_strong_ref_task branch February 27, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants