Skip to content

Commit

Permalink
Update PseudoDevice.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBooth committed Oct 28, 2023
1 parent b9cb7cc commit 3303963
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pybci/Utils/PseudoDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3303963

Please sign in to comment.