From 3303963f2d07e1b3d537b3c7a182cba4d2ff8983 Mon Sep 17 00:00:00 2001 From: LMBooth Date: Sat, 28 Oct 2023 12:39:54 +0100 Subject: [PATCH] Update PseudoDevice.py --- pybci/Utils/PseudoDevice.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pybci/Utils/PseudoDevice.py b/pybci/Utils/PseudoDevice.py index 00a8637..e765cd3 100644 --- a/pybci/Utils/PseudoDevice.py +++ b/pybci/Utils/PseudoDevice.py @@ -40,6 +40,7 @@ def __init__(self, execution_mode='process', *args, **kwargs): self.os_name = get_operating_system() print("os_name: "+self.os_name) print(self.os_name) # Output: Windows/macOS/Linux depending on the system + #self.os_name = "Linux" if self.os_name == 'Windows': if self.execution_mode == 'process': self.command_queue = Queue() @@ -50,9 +51,10 @@ def __init__(self, execution_mode='process', *args, **kwargs): else: print("got this mode:"+execution_mode) raise ValueError(f"Unsupported execution mode: {execution_mode}") + self.worker.start() else: self.device = PseudoDevice(*self.args, **self.kwargs, stop_signal=self.stop_signal) - self.worker.start() + def _run_device(self): device = PseudoDevice(*self.args, **self.kwargs, stop_signal=self.stop_signal) @@ -79,10 +81,13 @@ def BeginStreaming(self): # self.worker.BeginStreaming() def StopStreaming(self): - self.stop_signal.set() - self.worker.join(timeout=1) - if self.worker.is_alive(): - self.worker.terminate() + if self.os_name == 'Windows': + self.stop_signal.set() + self.worker.join(timeout=1) + if self.worker.is_alive(): + self.worker.terminate() + else: + self.device.StopStreaming() def precise_sleep(duration): end_time = time.time() + duration