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
|
|
@ -2,7 +2,7 @@ import random
|
|||
import time
|
||||
from openflexure_microscope.plugins import MicroscopePlugin
|
||||
|
||||
from .api import IdentifyAPI, HelloWorldAPI, LongRunningAPI
|
||||
from .api import IdentifyAPI, HelloWorldAPI, LongRunningAPI, SomeExceptionAPI
|
||||
|
||||
|
||||
class Plugin(MicroscopePlugin):
|
||||
|
|
@ -14,6 +14,7 @@ class Plugin(MicroscopePlugin):
|
|||
'/identify': IdentifyAPI,
|
||||
'/hello': HelloWorldAPI,
|
||||
'/long_running': LongRunningAPI,
|
||||
'/some_exception': SomeExceptionAPI,
|
||||
}
|
||||
|
||||
def identify(self):
|
||||
|
|
@ -32,6 +33,16 @@ class Plugin(MicroscopePlugin):
|
|||
|
||||
return "Hello world!"
|
||||
|
||||
def some_exception(self):
|
||||
"""
|
||||
Demonstrate some broken plugin method that would be long running
|
||||
"""
|
||||
with self.microscope.lock:
|
||||
time.sleep(3)
|
||||
result = 15./0
|
||||
|
||||
return result
|
||||
|
||||
def long_running(self, t_run):
|
||||
"""
|
||||
Demonstrate a long-running method that requires microscope hardware
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue