Skip to content

Commit

Permalink
Try to fix test on macos, multiprocessing seems to work different ...
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Dec 3, 2024
1 parent 43279b9 commit d4af92b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/ctapipe/core/tests/test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,23 +535,27 @@ class CustomError(ValueError):
assert provlog["status"] == expected_status


class InterruptTestTool(Tool):
name = "test-interrupt"

def __init__(self, barrier):
super().__init__()
self.barrier = barrier

def start(self):
self.barrier.wait()
signal.pause()


def test_exit_status_interrupted(tmp_path, provenance):
"""check that the config is correctly in the provenance"""

# to make sure we only kill the process once it is running
barrier = Barrier(2)

class MyTool(Tool):
name = "test-interrupt"

def start(self):
barrier.wait()
signal.pause()
tool = InterruptTestTool(barrier)

provenance_path = tmp_path / "provlog.json"

args = [f"--provenance-log={provenance_path}", "--log-level=INFO"]
tool = MyTool()
process = Process(target=run_tool, args=(tool, args), kwargs=dict(raises=False))
process.start()
barrier.wait()
Expand All @@ -563,5 +567,5 @@ def start(self):
activities = json.loads(provenance_path.read_text())
assert len(activities) == 1
provlog = activities[0]
assert provlog["activity_name"] == MyTool.name
assert provlog["activity_name"] == InterruptTestTool.name
assert provlog["status"] == "interrupted"

0 comments on commit d4af92b

Please sign in to comment.