8000 Skip finished tasks when checking for async leaked tasks by kchatzii · Pull Request #263 · facebook/TestSlide · GitHub
[go: up one dir, main page]

Skip to content

Skip finished tasks when checking for async leaked tasks #263

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

Merged
merged 1 commit into from
Nov 9, 2020

Conversation

kchatzii
Copy link
@kchatzii kchatzii commented Nov 9, 2020

What:
Updated leaked tasks checking to skip finished coroutines, in order to avoid incorrect failures when tasks have been completed

Why:
With Python versions that doesnt include this fix (python/cpython#7174), Testslide will raise a LeftOverActiveTasks exception even if all coroutines have been completed successfully.
Example:
<Task finished coro=<TestAsyncRun.test_catches_leaked_tasks.<locals>.dummy_async_func() done, defined at *> result=None created at *>

Although the task is done, Testslide will fail.

This PR skips finished tasks from the async leak testing

How:

  • Added extra function get_running_tasks to return only non done tasks
  • Updated _async_ensure_no_leaked_tasks to use this new function

Checklist:

  • Added tests, if you've added code that should be tested
  • Updated the documentation, if you've changed APIs
  • Ensured the test suite passes
  • Made sure your code lints
  • Completed the Contributor License Agreement ("CLA")

@deathowl deathowl self-requested a review November 9, 2020 17:36
@deathowl
Copy link
Member
deathowl commented Nov 9, 2020

Thanks for the PR @kchatzii

@deathowl deathowl merged commit c0ad165 into facebook:master Nov 9, 2020
@@ -72,6 +72,10 @@ def asyncio_run(coro):
get_all_tasks = asyncio.all_tasks


def get_running_tasks():
Copy link
Contributor

Choose a reason for hiding this comment

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

s/get_running_tasks/get_not_done_tasks/g.

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.

3 participants
0