Skip to content

Commit c798270

Browse files
committed
Don't start collection thread until hardware is enabled.
1 parent c5e9a37 commit c798270

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
@@ -440,18 +440,6 @@ def enable(self):
440440
Implement device-specific code in _on_enable .
441441
"""
442442
_logger.debug("Enabling ...")
443-
if self._using_callback:
444-
if self._fetch_thread:
445-
self._fetch_thread_run = False
446-
else:
447-
if not self._fetch_thread or not self._fetch_thread.is_alive():
448-
self._fetch_thread = Thread(target=self._fetch_loop)
449-
self._fetch_thread.daemon = True
450-
self._fetch_thread.start()
451-
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
452-
self._dispatch_thread = Thread(target=self._dispatch_loop)
453-
self._dispatch_thread.daemon = True
454-
self._dispatch_thread.start()
455443
# Call device-specific code.
456444
try:
457445
result = self._on_enable()
@@ -463,7 +451,20 @@ def enable(self):
463451
self.enabled = False
464452
else:
465453
self.enabled = True
466-
_logger.debug("... enabled.")
454+
# Set up data fetching
455+
if self._using_callback:
456+
if self._fetch_thread:
457+
self._fetch_thread_run = False
458+
else:
459+
if not self._fetch_thread or not self._fetch_thread.is_alive():
460+
self._fetch_thread = Thread(target=self._fetch_loop)
461+
self._fetch_thread.daemon = True
462+
self._fetch_thread.start()
463+
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
464+
self._dispatch_thread = Thread(target=self._dispatch_loop)
465+
self._dispatch_thread.daemon = True
466+
self._dispatch_thread.start()
467+
_logger.debug("... enabled.")
467468
return self.enabled
468469

469470

0 commit comments

Comments
 (0)