Commit 597e4844 authored by Dylan Baker's avatar Dylan Baker

framework: fix running with mixed concurrency (neither -c or -1)

test_list is an iterator, you can't walk an iterator more than once. To
solve this we use itertools.tee, which creates a shared buffer for the
iterators to draw from. This fixes errors like:

Traceback (most recent call last):
  File "./piglit", line 178, in <module>
  File "./piglit", line 174, in main
  File "/home/user/piglit/framework/", line 51, in _inner
    func(*args, **kwargs)
  File "/home/user/piglit/framework/programs/", line 370, in run
    backend.finalize({'time_elapsed': time_elapsed.to_json()})
  File "/home/user/piglit/framework/backends/", line 163, in finalize
    assert data['tests']

Thanks Tomi for figuring out what was wrong with the original patch!

CC: Tomi Sarvela <>
Tested-by: Michel Dänzer's avatarMichel Dänzer <>
Reviewed-by: Juan Suárez Romero's avatarJuan A. Suarez <>
parent 1e60f149
......@@ -596,13 +596,16 @@ def run(profiles, logger, backend, concurrency):
run_threads(single, profile, test_list)
assert concurrency == "some"
# test_list is an iterator, we need to copy it to run it twice.
test_list = itertools.tee(test_list, 2)
# Filter and return only thread safe tests to the threaded pool
run_threads(multi, profile, test_list,
run_threads(multi, profile, test_list[0],
lambda x: x[1].run_concurrent)
# Filter and return the non thread safe tests to the single
# pool
run_threads(single, profile, test_list,
run_threads(single, profile, test_list[1],
lambda x: not x[1].run_concurrent)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment