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

Replace loop.call_later and loop.add_callback with background tasks added to Server. #6603

Merged
merged 85 commits into from
Jun 23, 2022

Conversation

graingert
Copy link
Member

Closes #6359
#6478 with conflicts fixed and a few suggestions applied

This PR introduces a TaskGroup class that encapsulates scheduling behavior behind call_soon and call_later methods and allows gracefully shutting down all its tasks at once with a timeout.

Outside of scope:

* Replacing `loop.add_callback` and `loop.call_later` if the call is performed to another loop or the loop is not running.

* Avoiding multiple concurrent calls to `Server.close()`, the fastest one wins as before, now it just cancels the others.


* [x]  Tests added / passed (failing tests are [test_stress_scatter_death #6305](https://github.com/dask/distributed/issues/6305), [flaky test diagnostics/tests/test_progress.py::test_group_timing #6452](https://github.com/dask/distributed/issues/6452))

* [x]  Passes `pre-commit run --all-files`

hendrikmakait and others added 11 commits June 8, 2022 19:12
…call_later

it's very easy to accidentally call "await group.call_soon(set_flag)"
which is always wrong, this is especially bad because some type checkers
will warn you that you didn't await your awaitables here

also this prevents issues like
"task = group.call_soon(set_flag); ... await task" where it's easy to
confuse a cancellation coming from asyncio.current_task().cancel() and
task.cancelled() which should be handled differently
delayed already has a meaning in dask so we should
come up with a new name before making it public
this seems to have some difficult to understand consequences
and should be handled in dask#6548
@graingert
Copy link
Member Author

seemed to fail with #4498 last time

@graingert
Copy link
Member Author

Tests / test (ubuntu-latest, 3.8, not ci1) : #6045

@graingert
Copy link
Member Author

I think this PR should be squash merged

@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2022

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       15 files  ±  0         15 suites  ±0   10h 7m 49s ⏱️ + 2h 59m 38s
  2 890 tests +  8    2 805 ✔️ +12    83 💤  - 1  2  - 3 
21 408 runs  +56  20 441 ✔️ +59  965 💤 +1  2  - 4 

For more details on these failures, see this check.

Results for commit fc2f7e1. ± Comparison against base commit 7a0649a.

♻️ This comment has been updated with latest results.

@graingert graingert requested a review from fjetter June 23, 2022 09:09
@fjetter fjetter merged commit 4779f84 into dask:main Jun 23, 2022
@fjetter
Copy link
Member

fjetter commented Jun 23, 2022

Thank you @graingert and @hendrikmakait ! Really looking forward to having this 🎉

@crusaderky
Copy link
Collaborator

This PR has caused a major performance degradation in CI: #6632

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.

Replace loop.call_later and loop.add_callback with background tasks
4 participants