Skip to content

Commit

Permalink
avoid a task and a thread in the test_context_manager_used_from_diffe…
Browse files Browse the repository at this point in the history
…rent_x tests
  • Loading branch information
graingert committed Jul 12, 2023
1 parent f6aee09 commit f157a1c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions distributed/tests/test_client.py
Expand Up @@ -1277,7 +1277,7 @@ async def client_2():
@gen_cluster(client=False, nthreads=[])
async def test_context_manager_used_from_different_tasks(s):
c = Client(s.address, asynchronous=True)
await asyncio.create_task(c.__aenter__())
await c.__aenter__()
with pytest.warns(
DeprecationWarning,
match=r"It is deprecated to enter and exit the Client context manager "
Expand All @@ -1288,17 +1288,13 @@ async def test_context_manager_used_from_different_tasks(s):

def test_context_manager_used_from_different_threads(s, loop):
c = Client(s["address"])
with (
concurrent.futures.ThreadPoolExecutor(1) as tp1,
concurrent.futures.ThreadPoolExecutor(1) as tp2,
c.__enter__()
with concurrent.futures.ThreadPoolExecutor(1) as tpe, pytest.warns(
DeprecationWarning,
match=r"It is deprecated to enter and exit the Client context manager "
"from different threads",
):
tp1.submit(c.__enter__).result()
with pytest.warns(
DeprecationWarning,
match=r"It is deprecated to enter and exit the Client context manager "
"from different threads",
):
tp2.submit(c.__exit__, None, None, None).result()
tpe.submit(c.__exit__, None, None, None).result()


def test_global_clients(loop):
Expand Down

0 comments on commit f157a1c

Please sign in to comment.