Skip to content

Commit 84e042f

Browse files
committed
Don't start collection thread until hardware is enabled.
1 parent 7f11336 commit 84e042f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

microscope/devices.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,6 @@ def enable(self):
446446
Implement device-specific code in _on_enable .
447447
"""
448448
_logger.debug("Enabling ...")
449-
if self._using_callback:
450-
if self._fetch_thread:
451-
self._fetch_thread_run = False
452-
else:
453-
if not self._fetch_thread or not self._fetch_thread.is_alive():
454-
self._fetch_thread = Thread(target=self._fetch_loop)
455-
self._fetch_thread.daemon = True
456-
self._fetch_thread.start()
457-
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
458-
self._dispatch_thread = Thread(target=self._dispatch_loop)
459-
self._dispatch_thread.daemon = True
460-
self._dispatch_thread.start()
461449
# Call device-specific code.
462450
try:
463451
result = self._on_enable()
@@ -469,7 +457,20 @@ def enable(self):
469457
self.enabled = False
470458
else:
471459
self.enabled = True
472-
_logger.debug("... enabled.")
460+
# Set up data fetching
461+
if self._using_callback:
462+
if self._fetch_thread:
463+
self._fetch_thread_run = False
464+
else:
465+
if not self._fetch_thread or not self._fetch_thread.is_alive():
466+
self._fetch_thread = Thread(target=self._fetch_loop)
467+
self._fetch_thread.daemon = True
468+
self._fetch_thread.start()
469+
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
470+
self._dispatch_thread = Thread(target=self._dispatch_loop)
471+
self._dispatch_thread.daemon = True
472+
self._dispatch_thread.start()
473+
_logger.debug("... enabled.")
473474
return self.enabled
474475

475476

0 commit comments

Comments
 (0)