Added wait=bool argument to acquisitions (default: True). If a static acquire() is directly called, the task is waiting (/blocking) now. This allows to see the result or an exceptions without the need for calling wait() manually. For scans, acquire_all() sets wait=False such that tasks can still run in parallel.
This commit is contained in:
@@ -30,7 +30,7 @@ class Acquisition(BaseAcquisition):
|
||||
self.current_task = None
|
||||
|
||||
|
||||
def acquire(self, filename=None, channels=None, use_default_dir=True, **kwargs):
|
||||
def acquire(self, filename=None, channels=None, use_default_dir=True, wait=True, **kwargs):
|
||||
if filename and use_default_dir:
|
||||
filename = os.path.join(self.default_dir, filename)
|
||||
|
||||
@@ -47,6 +47,10 @@ class Acquisition(BaseAcquisition):
|
||||
|
||||
task = DAQTask(acq, filename=filename, hold=False)
|
||||
self.current_task = task
|
||||
|
||||
if wait:
|
||||
task.wait()
|
||||
|
||||
return task
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class DIAAcquisition(BaseAcquisition):
|
||||
self.current_task = None
|
||||
|
||||
|
||||
def acquire(self, filename=None, channels=None, n_pulses=100, use_default_dir=True, is_HG0=False):
|
||||
def acquire(self, filename=None, channels=None, n_pulses=100, use_default_dir=True, is_HG0=False, wait=True):
|
||||
if filename:
|
||||
if use_default_dir:
|
||||
filename = os.path.join(self.default_dir, filename)
|
||||
@@ -70,6 +70,10 @@ class DIAAcquisition(BaseAcquisition):
|
||||
|
||||
task = DAQTask(_acquire, stopper=self.client.stop, filenames=filenames, hold=False)
|
||||
self.current_task = task
|
||||
|
||||
if wait:
|
||||
task.wait()
|
||||
|
||||
return task
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class NuDIArAcquisition(BaseAcquisition):
|
||||
self.current_task = None
|
||||
|
||||
|
||||
def acquire(self, filename, channels=None, n_pulses=100):
|
||||
def acquire(self, filename, channels=None, n_pulses=100, wait=True):
|
||||
if not filename or filename == "/dev/null":
|
||||
print("Skipping retrieval since no filename was given.")
|
||||
return
|
||||
@@ -50,6 +50,10 @@ class NuDIArAcquisition(BaseAcquisition):
|
||||
|
||||
task = DAQTask(_acquire, stopper=client.stop, filename=filename, hold=False)
|
||||
self.current_task = task
|
||||
|
||||
if wait:
|
||||
task.wait()
|
||||
|
||||
return task
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class ScanBackend:
|
||||
def acquire_all(self, filename):
|
||||
tasks = []
|
||||
for acq in self.acquisitions:
|
||||
t = acq.acquire(filename=filename, channels=self.channels, n_pulses=self.n_pulses_per_step)
|
||||
t = acq.acquire(filename=filename, channels=self.channels, n_pulses=self.n_pulses_per_step, wait=False)
|
||||
tasks.append(t)
|
||||
|
||||
self.current_tasks = tasks
|
||||
|
||||
Reference in New Issue
Block a user