Skip to content

Commit 1fef4b3

Browse files
committed
Don't start collection thread until hardware is enabled.
1 parent 71850b3 commit 1fef4b3

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
@@ -438,18 +438,6 @@ def enable(self):
438438
Implement device-specific code in _on_enable .
439439
"""
440440
_logger.debug("Enabling ...")
441-
if self._using_callback:
442-
if self._fetch_thread:
443-
self._fetch_thread_run = False
444-
else:
445-
if not self._fetch_thread or not self._fetch_thread.is_alive():
446-
self._fetch_thread = Thread(target=self._fetch_loop)
447-
self._fetch_thread.daemon = True
448-
self._fetch_thread.start()
449-
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
450-
self._dispatch_thread = Thread(target=self._dispatch_loop)
451-
self._dispatch_thread.daemon = True
452-
self._dispatch_thread.start()
453441
# Call device-specific code.
454442
try:
455443
result = self._on_enable()
@@ -461,7 +449,20 @@ def enable(self):
461449
self.enabled = False
462450
else:
463451
self.enabled = True
464-
_logger.debug("... enabled.")
452+
# Set up data fetching
453+
if self._using_callback:
454+
if self._fetch_thread:
455+
self._fetch_thread_run = False
456+
else:
457+
if not self._fetch_thread or not self._fetch_thread.is_alive():
458+
self._fetch_thread = Thread(target=self._fetch_loop)
459+
self._fetch_thread.daemon = True
460+
self._fetch_thread.start()
461+
if not self._dispatch_thread or not self._dispatch_thread.is_alive():
462+
self._dispatch_thread = Thread(target=self._dispatch_loop)
463+
self._dispatch_thread.daemon = True
464+
self._dispatch_thread.start()
465+
_logger.debug("... enabled.")
465466
return self.enabled
466467

467468

0 commit comments

Comments
 (0)