Skip to content

Commit 1b566eb

Browse files
committed
Fix tests using wait
futures do not interpret `float('inf')` correctly so we need to change
1 parent ebc41c4 commit 1b566eb

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/aiida/engine/processes/control.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def _resolve_futures(
264264
# we unwrap to the end
265265
unwrapped = unwrap_kiwi_future(future)
266266
try:
267-
result = unwrapped.result(timeout=timeout)
267+
# future does not interpret float('inf') correctly by changing it to None we get the intended behavior
268+
result = unwrapped.result(timeout=None if timeout == float('inf') else timeout)
268269
except communications.TimeoutError:
269270
cancelled = future.cancel()
270271
if cancelled:

tests/engine/processes/test_control.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_pause_processes(submit_and_await):
3535
node = submit_and_await(WaitProcess, ProcessState.WAITING)
3636
assert not node.paused
3737

38-
control.pause_processes([node], wait=True)
38+
control.pause_processes([node], timeout=float('inf'))
3939
assert node.paused
4040
assert node.process_status == 'Paused through `aiida.engine.processes.control.pause_processes`'
4141

@@ -46,7 +46,7 @@ def test_pause_processes_all_entries(submit_and_await):
4646
node = submit_and_await(WaitProcess, ProcessState.WAITING)
4747
assert not node.paused
4848

49-
control.pause_processes(all_entries=True, wait=True)
49+
control.pause_processes(all_entries=True, timeout=float('inf'))
5050
assert node.paused
5151

5252

@@ -56,10 +56,10 @@ def test_play_processes(submit_and_await):
5656
node = submit_and_await(WaitProcess, ProcessState.WAITING)
5757
assert not node.paused
5858

59-
control.pause_processes([node], wait=True)
59+
control.pause_processes([node], timeout=float('inf'))
6060
assert node.paused
6161

62-
control.play_processes([node], wait=True)
62+
control.play_processes([node], timeout=float('inf'))
6363
assert not node.paused
6464

6565

@@ -69,10 +69,10 @@ def test_play_processes_all_entries(submit_and_await):
6969
node = submit_and_await(WaitProcess, ProcessState.WAITING)
7070
assert not node.paused
7171

72-
control.pause_processes([node], wait=True)
72+
control.pause_processes([node], timeout=float('inf'))
7373
assert node.paused
7474

75-
control.play_processes(all_entries=True, wait=True)
75+
control.play_processes(all_entries=True, timeout=float('inf'))
7676
assert not node.paused
7777

7878

@@ -81,7 +81,7 @@ def test_kill_processes(submit_and_await):
8181
"""Test :func:`aiida.engine.processes.control.kill_processes`."""
8282
node = submit_and_await(WaitProcess, ProcessState.WAITING)
8383

84-
control.kill_processes([node], wait=True)
84+
control.kill_processes([node], timeout=float('inf'))
8585
assert node.is_terminated
8686
assert node.is_killed
8787
assert node.process_status == 'Killed through `aiida.engine.processes.control.kill_processes`'
@@ -92,7 +92,7 @@ def test_kill_processes_all_entries(submit_and_await):
9292
"""Test :func:`aiida.engine.processes.control.kill_processes` with ``all_entries=True``."""
9393
node = submit_and_await(WaitProcess, ProcessState.WAITING)
9494

95-
control.kill_processes(all_entries=True, wait=True)
95+
control.kill_processes(all_entries=True, timeout=float('inf'))
9696
assert node.is_terminated
9797
assert node.is_killed
9898

0 commit comments

Comments
 (0)