Commit cdbc196
authored
Avoid frequent test failure in greedy_test.py by increasing timeout (#7188)
* Fix frequent test failure in greedy_test.py
On my MacOS 15.x Apple M1 laptop, I frequently get a test failure in
`cirq-core/cirq/contrib/routing/greedy_test.py`:
```
[gw2] darwin -- Python 3.11.9 /Users/mhucka/.pyenv/versions/cirq-py311-np1/bin/python3
def test_router_hanging():
"""Run a separate process and check if greedy router hits timeout (5s)."""
circuit, device_graph = create_circuit_and_device()
process = Process(target=create_hanging_routing_instance, args=[circuit, device_graph])
process.start()
process.join(timeout=5)
try:
> assert not process.is_alive(), "Greedy router timeout"
E AssertionError: Greedy router timeout
E assert not True
E + where True = is_alive()
E + where is_alive = <Process name='Process-1' pid=58097 parent=56380 started>.is_alive
cirq-core/cirq/contrib/routing/greedy_test.py:58: AssertionError
```
This happens with Python 3.10 and 3.12 as well.
Since assertion being tested is that the process is _not_ alive, it
seems that 5 seconds can be too short. And indeed, the timeout is
increased to 20 seconds, the error never seems to occur in my local
Mac testing.
It's not obvious whether a short timeout is needed for the purposes
of the test. Shortening the duration to 10 sec also works, but might
not in other people's environments. So, 20 sec seems safer. However,
if it needs to be as short as possible, then 10 seconds seems workable
too.
* Update docstring to match change in code1 parent c95af3e commit cdbc196
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
0 commit comments