Skip to content

Commit

Permalink
Use module-level Random to shuffle tasks
Browse files Browse the repository at this point in the history
This allows test helpers etc. to reproduce scheduling-dependent heisenbugs by seeding the Random instance.

Or at least ensures that *something else* will prevent reproductions instead.
  • Loading branch information
Zac-HD committed Jan 6, 2019
1 parent b208624 commit 73d397e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ class Runner:

runq = attr.ib(default=attr.Factory(deque))
tasks = attr.ib(default=attr.Factory(set))
r = attr.ib(default=attr.Factory(random.Random))

# {(deadline, id(CancelScope)): CancelScope}
# only contains scopes with non-infinite deadlines that are currently
Expand Down Expand Up @@ -1433,7 +1432,7 @@ def run_impl(runner, async_fn, args):
# ordering of task._notify_queues.)
batch = list(runner.runq)
runner.runq.clear()
runner.r.shuffle(batch)
_r.shuffle(batch)
while batch:
task = batch.pop()
GLOBAL_RUN_CONTEXT.task = task
Expand Down

0 comments on commit 73d397e

Please sign in to comment.