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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
33ae2ef
Add background tasks and rename ongoing_coroutines to ongoing_comm_ha…
hendrikmakait May 24, 2022
e680be9
Replace add_callback and call_later
hendrikmakait May 25, 2022
0af0741
Move close out of background tasks since it would cancel itself
hendrikmakait May 25, 2022
d9ce34f
Fix issue with non-running IO loop
hendrikmakait May 25, 2022
89f70db
Remove deprecated asyncio.coroutine
hendrikmakait May 25, 2022
76edf23
Add delay decorator to delay async function evaluation
hendrikmakait May 27, 2022
e415d97
Replace add_callback in nanny
hendrikmakait May 27, 2022
3d688ad
Add docstring and rename to create_background_task
hendrikmakait May 27, 2022
d91a4cf
Factor functionality out into TaskGroup and adjust interface to avoid…
hendrikmakait May 27, 2022
8312041
Rename
hendrikmakait May 27, 2022
488b111
Revert changes to log_event
hendrikmakait May 27, 2022
9155235
Revert changes to lifetime callback
hendrikmakait May 30, 2022
62c9383
Fix test
hendrikmakait May 30, 2022
96c6346
Ignore cancelled error when awaiting finished()
hendrikmakait May 30, 2022
0248587
Fix test
hendrikmakait May 30, 2022
3a5695a
Fix test for adaptive scaling by adjusting wait condition
hendrikmakait May 30, 2022
aaa3cd4
Enable tmate for remote debugging of flaking tests
hendrikmakait May 30, 2022
b271783
Re-raise exception unless cancelled
hendrikmakait May 30, 2022
5459964
Re-raise exception unless cancelled
hendrikmakait May 30, 2022
773188a
Fix '_GatheringFuture exception was never retrieved'
hendrikmakait May 30, 2022
734e893
Catch cancellederror on cancelled gather
hendrikmakait May 30, 2022
bc45f99
Revert changes to tests.yaml
hendrikmakait May 30, 2022
a932b79
Replace _ongoing_comm_handlers with TaskGroup
hendrikmakait May 31, 2022
bb9d71b
Add docstrings
hendrikmakait May 31, 2022
eda6b73
Improved docs
hendrikmakait May 31, 2022
79970d7
Improve typing
hendrikmakait May 31, 2022
bdb1b70
Fix typing of delayed
hendrikmakait May 31, 2022
d3f04a5
Adjust stop()
hendrikmakait May 31, 2022
0532a21
Adjust stop()
hendrikmakait May 31, 2022
ac53b94
Make call_soon and call_later public
hendrikmakait May 31, 2022
2f7d90c
Make TypeVar private
hendrikmakait May 31, 2022
4f739b2
Rename TaskGroup to AsyncTaskGroup
hendrikmakait May 31, 2022
f6348ee
Minor
hendrikmakait May 31, 2022
b66fae6
Fix stop() without running tasks
hendrikmakait May 31, 2022
b064ba1
Wrap gather in async def
hendrikmakait Jun 1, 2022
52061d9
Add __len__ to AsyncTaskGroup
hendrikmakait Jun 1, 2022
1e41e20
Fix comm handling and delayed typing
hendrikmakait Jun 1, 2022
688aaa1
Fix test
hendrikmakait Jun 1, 2022
f3d9fa9
Add unit tests for AsyncTaskGroup
hendrikmakait Jun 1, 2022
ad70db2
Merge branch 'main' into background-tasks
hendrikmakait Jun 1, 2022
1b28c3b
Merge branch 'main' into background-tasks
hendrikmakait Jun 1, 2022
683d837
Replace more add_callback's
hendrikmakait Jun 1, 2022
350c2b4
Add hopefully unreachable error
hendrikmakait Jun 1, 2022
43c7b3c
Rollback to add_callback in fail_hard
hendrikmakait Jun 2, 2022
fddd34c
Merge branch 'main' into background-tasks
hendrikmakait Jun 2, 2022
936710a
Retrigger CI to check for flake
hendrikmakait Jun 2, 2022
f46bc59
Clean up closing logic
hendrikmakait Jun 2, 2022
06749bb
Add locking
hendrikmakait Jun 2, 2022
9ca5bea
Fix invalid worker states by not tracking handle_scheduler
hendrikmakait Jun 2, 2022
daa845a
Fix call_later test by using monotonic clock and subtracting clock re…
hendrikmakait Jun 2, 2022
be622fd
Merge branch 'main' into background-tasks
hendrikmakait Jun 3, 2022
075a539
Drop lock and ensure AsyncTaskGroup is called from the correct thread
hendrikmakait Jun 7, 2022
8df26a5
Raise exception if coro cannot be scheduled
hendrikmakait Jun 8, 2022
a77c61e
AsyncTaskGroupClosedError
hendrikmakait Jun 8, 2022
50f5851
Add comment
hendrikmakait Jun 8, 2022
22d0952
Use ParamSpec
hendrikmakait Jun 8, 2022
d5b99ef
Merge branch 'main' into background-tasks
hendrikmakait Jun 8, 2022
cd04ab2
Fix ParamSpec
hendrikmakait Jun 8, 2022
2daae46
Fix tests
hendrikmakait Jun 8, 2022
55bcdd3
Drop wrapper methods to highlight which group is being used
hendrikmakait Jun 8, 2022
6c4536c
Fix tests errors after cleanup
hendrikmakait Jun 8, 2022
53643cd
Fix inproc cancel handling and simplify pc startup
hendrikmakait Jun 8, 2022
2494e40
Drop AsyncTaskGroup.schedule()
hendrikmakait Jun 8, 2022
2751c52
Add comment
hendrikmakait Jun 8, 2022
93ff2ba
Fix f-string
hendrikmakait Jun 8, 2022
e76489c
Abort comm if we cannot handle it
hendrikmakait Jun 8, 2022
09a3b2c
Fix listener.stop
hendrikmakait Jun 8, 2022
a7df081
Add comment
hendrikmakait Jun 8, 2022
8873ccb
Test idempotency
hendrikmakait Jun 8, 2022
733e419
Merge branch 'main' of github.com:dask/distributed into background-tasks
graingert Jun 20, 2022
6a308ba
do not return tasks from AsyncTaskGroup.call_soon and AsyncTaskGroup.…
graingert Jun 20, 2022
35fc707
avoid deprecated loop kwarg
graingert Jun 21, 2022
753c6ce
don't log periodic callback starts
graingert Jun 21, 2022
3902842
move d.core.delayed into private d.utils._delayed
graingert Jun 21, 2022
2cf6e91
remove unused IOLoop import
graingert Jun 21, 2022
e53245f
Merge branch 'main' of github.com:dask/distributed into background-tasks
graingert Jun 21, 2022
e0ae0f9
back out cancellation changes to inproc
graingert Jun 21, 2022
2714ccc
fix ERROR - Failed while closing connection to 'inproc://...': invali…
graingert Jun 21, 2022
e6a0eeb
remove whitespace/typing import changes to distributed/utils.py
graingert Jun 21, 2022
d01c6cb
Merge branch 'main' into background-tasks
graingert Jun 22, 2022
253694d
complete type annotation for AsyncTaskGroup.stop
graingert Jun 22, 2022
a8244bd
lock close to prevent it cancelling concurrent closes and always set …
graingert Jun 22, 2022
a9d5651
Merge branch 'main' of github.com:dask/distributed into background-tasks
graingert Jun 22, 2022
d04f551
remove the close lock, setting the close event in finally should be
graingert Jun 23, 2022
fc2f7e1
Merge branch 'main' of github.com:dask/distributed into background-tasks
graingert Jun 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions distributed/cli/dask_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import click
from tlz import valmap
from tornado.ioloop import IOLoop, TimeoutError
from tornado.ioloop import TimeoutError

import dask
from dask.system import CPU_COUNT
Expand Down Expand Up @@ -448,14 +448,11 @@ def del_pid_file():
signal_fired = False

async def run():
loop = IOLoop.current()

nannies = [
t(
scheduler,
scheduler_file=scheduler_file,
nthreads=nthreads,
loop=loop,
resources=resources,
security=sec,
contact_address=contact_address,
Expand Down
9 changes: 8 additions & 1 deletion distributed/comm/inproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class QueueEmpty(Exception):
pass


def _set_result_unless_cancelled(fut, result):
"""Helper setting the result only if the future was not cancelled."""
if fut.cancelled():
return
fut.set_result(result)


class Queue:
"""
A single-reader, single-writer, non-threadsafe, peekable queue.
Expand Down Expand Up @@ -119,7 +126,7 @@ def put_nowait(self, value):
if fut is not None:
assert len(q) == 0
self._read_future = None
fut.set_result(value)
_set_result_unless_cancelled(fut, value)
else:
q.append(value)

Expand Down
Loading