Updated to use taskify
This commit is contained in:
parent
d8cfc412e3
commit
0db0a89092
1 changed files with 3 additions and 2 deletions
|
|
@ -74,10 +74,11 @@ For example, a timelapse plugin may look like:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from openflexure_microscope.plugins import MicroscopePlugin
|
from openflexure_microscope.plugins import MicroscopePlugin
|
||||||
from openflexure_microscope.exceptions import TaskDeniedException
|
|
||||||
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
|
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
|
||||||
from openflexure_microscope.api.utilities import JsonResponse
|
from openflexure_microscope.api.utilities import JsonResponse
|
||||||
|
|
||||||
|
from openflexure_microscope.common.tasks import taskify
|
||||||
|
|
||||||
|
|
||||||
### MICROSCOPE PLUGIN ###
|
### MICROSCOPE PLUGIN ###
|
||||||
|
|
||||||
|
|
@ -128,7 +129,7 @@ For example, a timelapse plugin may look like:
|
||||||
n_images = payload.param('n_images', default=10, convert=int)
|
n_images = payload.param('n_images', default=10, convert=int)
|
||||||
|
|
||||||
# Attach the long-running method as a microscope task
|
# Attach the long-running method as a microscope task
|
||||||
self.timelapse_task = self.microscope.task.start(self.plugin.timelapse, n_images)
|
self.timelapse_task = taskify(self.plugin.timelapse)(n_images)
|
||||||
|
|
||||||
# Return the state of the task (will show ID, start time, and status before the task has finished)
|
# Return the state of the task (will show ID, start time, and status before the task has finished)
|
||||||
return jsonify(self.timelapse_task.state), 202
|
return jsonify(self.timelapse_task.state), 202
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue