Skip to content

always bind the Scheduler to the IOLoop.current() - and deprecate the Scheduler(loop= kwarg #6443

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 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions distributed/cli/dask_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import warnings

import click
from tornado.ioloop import IOLoop

from distributed import Scheduler
from distributed._signals import wait_for_signals
Expand Down Expand Up @@ -186,11 +185,9 @@ def del_pid_file():
resource.setrlimit(resource.RLIMIT_NOFILE, (limit, hard))

async def run():
loop = IOLoop.current()
logger.info("-" * 47)

scheduler = Scheduler(
loop=loop,
security=sec,
host=host,
port=port,
Expand Down
9 changes: 8 additions & 1 deletion distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,14 @@ def __init__(
transition_counter_max=False,
**kwargs,
):
if loop is not None:
warnings.warn(
"the loop kwarg to Scheduler is deprecated",
DeprecationWarning,
stacklevel=2,
)

self.loop = IOLoop.current()
self._setup_logging(logger)

# Attributes
Expand Down Expand Up @@ -2961,7 +2969,6 @@ def __init__(
)

# Communication state
self.loop = loop or IOLoop.current()
self.client_comms = {}
self.stream_comms = {}
self._worker_coroutines = []
Expand Down
11 changes: 9 additions & 2 deletions distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import psutil
import pytest
from tlz import concat, first, merge, valmap
from tornado.ioloop import IOLoop

import dask
from dask import delayed
Expand Down Expand Up @@ -779,8 +780,14 @@ async def test_update_graph_culls(s, a, b):


def test_io_loop(loop):
s = Scheduler(loop=loop, dashboard_address=":0", validate=True)
assert s.io_loop is loop
async def main():
with pytest.warns(
DeprecationWarning, match=r"the loop kwarg to Scheduler is deprecated"
):
s = Scheduler(loop=loop, dashboard_address=":0", validate=True)
assert s.io_loop is IOLoop.current()

asyncio.run(main())


@gen_cluster(client=True)
Expand Down