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

Fix asyncio.create_task() calls #7300

Merged
merged 1 commit into from
Feb 27, 2023
Merged

Fix asyncio.create_task() calls #7300

merged 1 commit into from
Feb 27, 2023

Conversation

drew2a
Copy link
Contributor

@drew2a drew2a commented Feb 21, 2023

This PR fixes #7299

  • shutdown method has been added to the RestEndpoint base class
  • List[Task] has been added as a result value of the AsyncGroup.add() call
  • Calls of asyncio.create_task have been fixed

@drew2a drew2a marked this pull request as ready for review February 21, 2023 13:41
@drew2a drew2a requested a review from a team February 21, 2023 13:41
@drew2a drew2a marked this pull request as draft February 21, 2023 13:49
@drew2a drew2a changed the title Fix asyncio.create_task() calls WIP: Fix asyncio.create_task() calls Feb 21, 2023
@drew2a drew2a changed the title WIP: Fix asyncio.create_task() calls Fix asyncio.create_task() calls Feb 22, 2023
@drew2a drew2a marked this pull request as ready for review February 22, 2023 10:01
Copy link
Contributor

@kozlovsky kozlovsky left a comment

Choose a reason for hiding this comment

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

Overall looks good. I think I found some other places where asyncio.create_task is used dangerously:

  • In Service._graceful_shutdown, file hidden_peer_discovery.py:
    def _graceful_shutdown(self):
        task = asyncio.create_task(self.on_tribler_shutdown())
        task.add_done_callback(lambda result: TinyTriblerService._graceful_shutdown(self))

the variable is created, but its lifetime is shorter than the lifetime of the task.

  • In Service._graceful_shutdown, file speed_test_exit.py - the same.

@drew2a
Copy link
Contributor Author

drew2a commented Feb 27, 2023

@kozlovsky thank you for your review. Two calls of Service._graceful_shutdown were fixed.

@drew2a drew2a merged commit 94f64e7 into Tribler:main Feb 27, 2023
@drew2a drew2a deleted the fix/7299 branch February 27, 2023 11:10
@drew2a drew2a mentioned this pull request Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Potential asyncio.create_task issue
2 participants