Skip to content

Commit 283a88c

Browse files
authored
Fix test_two_consecutive_clients_share_results (#8484)
1 parent ade01b3 commit 283a88c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

distributed/tests/test_client.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -1008,17 +1008,23 @@ async def test_map_quotes(c, s, a, b):
10081008
assert all(result)
10091009

10101010

1011-
@gen_cluster()
1012-
async def test_two_consecutive_clients_share_results(s, a, b):
1013-
async with Client(s.address, asynchronous=True) as c:
1014-
x = c.submit(random.randint, 0, 1000, pure=True)
1015-
xx = await x
1011+
@gen_cluster(client=True)
1012+
async def test_two_consecutive_clients_share_results(c, s, a, b):
1013+
# Calling c.submit(random.randint) directly would cause the client to tokenize and
1014+
# deep-copy the global random state. Also, Client and/or Scheduler draw from the
1015+
# global random state, so its state (and thus, token) would be different between the
1016+
# two calls to submit().
1017+
def f():
1018+
return random.randint(0, 1000)
10161019

1017-
async with Client(s.address, asynchronous=True) as f:
1018-
y = f.submit(random.randint, 0, 1000, pure=True)
1019-
yy = await y
1020+
x = c.submit(f)
1021+
xx = await x
1022+
1023+
async with Client(s.address, asynchronous=True) as c2:
1024+
y = c2.submit(f)
1025+
yy = await y
10201026

1021-
assert xx == yy
1027+
assert xx == yy
10221028

10231029

10241030
@gen_cluster(client=True)

0 commit comments

Comments
 (0)