|
28 | 28 | ComputeTaskEvent, |
29 | 29 | ExecuteFailureEvent, |
30 | 30 | ExecuteSuccessEvent, |
| 31 | + FreeKeysEvent, |
31 | 32 | GatherDep, |
32 | 33 | Instruction, |
33 | 34 | PauseEvent, |
@@ -1037,3 +1038,58 @@ async def test_clean_log(s, a, b): |
1037 | 1038 | """Test that brand new workers start with a clean log""" |
1038 | 1039 | assert not a.state.log |
1039 | 1040 | assert not a.state.stimulus_log |
| 1041 | + |
| 1042 | + |
| 1043 | +def test_running_task_in_all_running_tasks(ws_with_running_task): |
| 1044 | + ws = ws_with_running_task |
| 1045 | + ws2 = "127.0.0.1:2" |
| 1046 | + ts = ws.tasks["x"] |
| 1047 | + assert ts in ws.all_running_tasks |
| 1048 | + |
| 1049 | + ws.handle_stimulus(FreeKeysEvent(keys=["x"], stimulus_id="s1")) |
| 1050 | + assert ts.state == "cancelled" |
| 1051 | + assert ts in ws.all_running_tasks |
| 1052 | + |
| 1053 | + ws.handle_stimulus( |
| 1054 | + ComputeTaskEvent.dummy("y", who_has={"x": [ws2]}, stimulus_id="s2") |
| 1055 | + ) |
| 1056 | + assert ts.state == "resumed" |
| 1057 | + assert ts in ws.all_running_tasks |
| 1058 | + |
| 1059 | + |
| 1060 | +@pytest.mark.xfail(reason="distributed#6565, distributed#6692") |
| 1061 | +@pytest.mark.parametrize( |
| 1062 | + "done_ev_cls,done_status", |
| 1063 | + [(ExecuteSuccessEvent, "memory"), (ExecuteFailureEvent, "error")], |
| 1064 | +) |
| 1065 | +def test_done_task_not_in_all_running_tasks( |
| 1066 | + ws_with_running_task, done_ev_cls, done_status |
| 1067 | +): |
| 1068 | + ws = ws_with_running_task |
| 1069 | + ts = ws.tasks["x"] |
| 1070 | + assert ts in ws.all_running_tasks |
| 1071 | + |
| 1072 | + ws.handle_stimulus(done_ev_cls.dummy("x", stimulus_id="s1")) |
| 1073 | + assert ts.state == done_status |
| 1074 | + assert ts not in ws.all_running_tasks |
| 1075 | + |
| 1076 | + |
| 1077 | +@pytest.mark.xfail(reason="distributed#6565, distributed#6689, distributed#6692") |
| 1078 | +@pytest.mark.parametrize( |
| 1079 | + "done_ev_cls,done_status", |
| 1080 | + [(ExecuteSuccessEvent, "memory"), (ExecuteFailureEvent, "error")], |
| 1081 | +) |
| 1082 | +def test_done_resumed_task_not_in_all_running_tasks( |
| 1083 | + ws_with_running_task, done_ev_cls, done_status |
| 1084 | +): |
| 1085 | + ws = ws_with_running_task |
| 1086 | + ws2 = "127.0.0.1:2" |
| 1087 | + |
| 1088 | + ws.handle_stimulus( |
| 1089 | + FreeKeysEvent(keys=["x"], stimulus_id="s1"), |
| 1090 | + ComputeTaskEvent.dummy("y", who_has={"x": [ws2]}, stimulus_id="s2"), |
| 1091 | + done_ev_cls.dummy("x", stimulus_id="s3"), |
| 1092 | + ) |
| 1093 | + ts = ws.tasks["x"] |
| 1094 | + assert ts.state == done_status |
| 1095 | + assert ts not in ws.all_running_tasks |
0 commit comments