Fixed broken error handling for long-running tasks
This commit is contained in:
parent
e3a27b024a
commit
a11d2145d9
5 changed files with 45 additions and 4 deletions
|
|
@ -72,5 +72,24 @@ class LongRunningAPI(MicroscopeViewPlugin):
|
|||
task = self.microscope.task.start(self.plugin.long_running, time_to_run)
|
||||
return jsonify(task.state), 202
|
||||
|
||||
except TaskDeniedException:
|
||||
return abort(409)
|
||||
|
||||
class SomeExceptionAPI(MicroscopeViewPlugin):
|
||||
"""
|
||||
An example API plugin that uses a long-running but broken plugin method.
|
||||
"""
|
||||
def post(self):
|
||||
"""
|
||||
Method to call when an HTTP POST request is made.
|
||||
"""
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
|
||||
# Attach the long-running method as a microscope task
|
||||
try:
|
||||
task = self.microscope.task.start(self.plugin.some_exception)
|
||||
return jsonify(task.state), 202
|
||||
|
||||
except TaskDeniedException:
|
||||
return abort(409)
|
||||
Loading…
Add table
Add a link
Reference in a new issue