Skip to content

Commit

Permalink
more robust test_steal_more_attractive_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Aug 3, 2023
1 parent 18a6f31 commit c002bd9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion distributed/tests/test_steal.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,20 +641,29 @@ async def test_steal_when_more_tasks(c, s, a, *rest):
"slowidentity": 0.2,
"slow2": 1,
},
"distributed.scheduler.work-stealing-interval": "20ms",
},
)
async def test_steal_more_attractive_tasks(c, s, a, *rest):
ext = s.extensions["stealing"]

def slow2(x):
sleep(1)
return x

x = c.submit(mul, b"0", 100000000, workers=a.address) # 100 MB
await wait(x)

# We have to stop the extension entirely since otherwise a tick might
# already allow a stealing request may sneak in before all tasks are on the
# scheduler
await ext.stop()
futures = [c.submit(slowidentity, x, pure=False, delay=0.2) for i in range(10)]
future = c.submit(slow2, x, priority=-1)

while future.key not in s.tasks:
await asyncio.sleep(0.01)
# Now call it once explicitly to move the heavy task
ext.balance()
while not any(w.state.tasks for w in rest):
await asyncio.sleep(0.01)

Expand Down

0 comments on commit c002bd9

Please sign in to comment.