Skip to content

Commit

Permalink
set atexit in mockupcamera
Browse files Browse the repository at this point in the history
  • Loading branch information
walesch-yan committed Mar 3, 2025
1 parent 240212d commit 37aca15
Show file tree
Hide file tree
Showing 3 changed files with 317 additions and 12 deletions.
9 changes: 9 additions & 0 deletions mxcubecore/HardwareObjects/mockup/MDCameraMockup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Class for cameras connected to framegrabbers run by Taco Device Servers"""

import atexit
import logging
import os
import signal
import subprocess
import time
from typing import (
Expand Down Expand Up @@ -115,6 +118,10 @@ def get_stream_size(self) -> Tuple[int, int, float]:
scale = float(width) / self.get_width()
return (width, height, scale)

def clean_up(self):
logging.getLogger("HWR").info("Shutting down video_stream...")
os.kill(self._video_stream_process.pid, signal.SIGTERM)

def start_video_stream_process(self) -> None:
if (
not self._video_stream_process
Expand All @@ -141,6 +148,8 @@ def start_video_stream_process(self) -> None:
close_fds=True,
)

atexit.register(self.clean_up)

def stop_streaming(self) -> None:
if self._video_stream_process:
try:
Expand Down
Loading

0 comments on commit 37aca15

Please sign in to comment.