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

Enable support for tornado 6.2 #7134

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
- sortedcollections
- tblib
- toolz
- tornado<6.2
- tornado >=6.2
- zict # overridden by git tip below
- zstandard >=0.9.0
- pip:
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies:
- sortedcollections
- tblib
- toolz
- tornado<6.2
- tornado >=6.2
- zict
- zstandard >=0.9.0
- pip:
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/environment-3.9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies:
- tblib
- toolz
- torchvision # Only tested here
- tornado<6.2
- tornado >=6.2
- zict
- zstandard >=0.9.0
- pip:
Expand Down
2 changes: 1 addition & 1 deletion continuous_integration/recipes/distributed/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ requirements:
- sortedcontainers !=2.0.0,!=2.0.1
- tblib >=1.6.0
- toolz >=0.8.2
- tornado >=6.0.3,<6.2
- tornado >=6.2
- urllib3
- zict >=0.1.3
run_constrained:
Expand Down
1 change: 1 addition & 0 deletions distributed/deploy/tests/test_adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ async def test_no_more_workers_than_tasks():


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_basic_no_loop(cleanup):
loop = None
try:
Expand Down
1 change: 1 addition & 0 deletions distributed/deploy/tests/test_spec_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_spec_sync(loop):


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_loop_started_in_constructor(cleanup):
# test that SpecCluster.__init__ starts a loop in another thread
cluster = SpecCluster(worker_spec, scheduler=scheduler, loop=None)
graingert marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
40 changes: 3 additions & 37 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,27 +2205,8 @@ async def test_multi_client(s, a, b):
await asyncio.sleep(0.01)


@contextmanager
def _pristine_loop():
IOLoop.clear_instance()
IOLoop.clear_current()
loop = IOLoop()
loop.make_current()
assert IOLoop.current() is loop
try:
yield loop
finally:
try:
loop.close(all_fds=True)
except (KeyError, ValueError):
pass
IOLoop.clear_instance()
IOLoop.clear_current()


def long_running_client_connection(address):
with _pristine_loop():
c = Client(address)
with Client(address) as c:
x = c.submit(lambda x: x + 1, 10)
x.result()
sleep(100)
wence- marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -2889,6 +2870,7 @@ async def test_startup_close_startup(s, a, b):


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_startup_close_startup_sync(loop):
with cluster() as (s, [a, b]):
with Client(s["address"], loop=loop) as c:
Expand Down Expand Up @@ -5612,23 +5594,6 @@ async def test_future_auto_inform(c, s, a, b):
await asyncio.sleep(0.01)


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
def test_client_async_before_loop_starts(cleanup):
async def close():
async with client:
pass

with _pristine_loop() as loop:
with pytest.warns(
DeprecationWarning,
match=r"Constructing LoopRunner\(loop=loop\) without a running loop is deprecated",
):
client = Client(asynchronous=True, loop=loop)
assert client.asynchronous
assert isinstance(client.close(), NoOpAwaitable)
loop.run_sync(close) # TODO: client.close() does not unset global client


@pytest.mark.slow
@gen_cluster(client=True, Worker=Nanny, timeout=60, nthreads=[("127.0.0.1", 3)] * 2)
async def test_nested_compute(c, s, a, b):
Expand Down Expand Up @@ -6924,6 +6889,7 @@ async def test_workers_collection_restriction(c, s, a, b):


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
@gen_cluster(client=True, nthreads=[("127.0.0.1", 1)])
async def test_get_client_functions_spawn_clusters(c, s, a):
# see gh4565
Expand Down
2 changes: 2 additions & 0 deletions distributed/tests/test_client_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def _check_cluster_and_client_loop(loop):

# Test if Client stops LoopRunner on close.
@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_close_loop_sync_start_new_loop(cleanup):
with _check_loop_runner():
_check_cluster_and_client_loop(loop=None)


# Test if Client stops LoopRunner on close.
@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_close_loop_sync_use_running_loop(cleanup):
with _check_loop_runner():
# Start own loop or use current thread's one.
Expand Down
2 changes: 2 additions & 0 deletions distributed/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def assert_not_running(loop):


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_loop_runner(loop_in_thread):
# Implicit loop
loop = IOLoop()
Expand Down Expand Up @@ -488,6 +489,7 @@ def test_loop_runner(loop_in_thread):


@pytest.mark.filterwarnings("ignore:There is no current event loop:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:make_current is deprecated:DeprecationWarning")
def test_two_loop_runners(loop_in_thread):
# Loop runners tied to the same loop should cooperate

Expand Down
16 changes: 6 additions & 10 deletions distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,19 @@ def __init__(self, loop=None, asynchronous=False):
if asynchronous:
try:
asyncio.get_running_loop()
except RuntimeError:
warnings.warn(
"Constructing a LoopRunner(asynchronous=True) without a running loop is deprecated",
DeprecationWarning,
stacklevel=2,
)
except RuntimeError as e:
raise RuntimeError(
"Constructing a LoopRunner(asynchronous=True) without a running loop is not allowed"
) from e
self._loop = IOLoop.current()
else:
# We're expecting the loop to run in another thread,
# avoid re-using this thread's assigned loop
self._loop = IOLoop()
else:
if not loop.asyncio_loop.is_running():
warnings.warn(
"Constructing LoopRunner(loop=loop) without a running loop is deprecated",
DeprecationWarning,
stacklevel=2,
raise RuntimeError(
"Constructing LoopRunner(loop=loop) without a running loop is not allowed"
)
self._loop = loop
self._asynchronous = asynchronous
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ psutil >= 5.0
sortedcontainers !=2.0.0, !=2.0.1
tblib >= 1.6.0
toolz >= 0.8.2
tornado >= 6.0.3, <6.2
tornado >= 6.2
graingert marked this conversation as resolved.
Show resolved Hide resolved
urllib3
zict >= 0.1.3
pyyaml