File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from functools import wraps
2121from traceback import format_exc
2222
23- from pebble .common import launch_thread
23+ from pebble .common import execute , launch_thread , SUCCESS
2424
2525
2626def thread (* args , ** kwargs ) -> Callable :
@@ -79,13 +79,12 @@ def _function_handler(
7979 """Runs the actual function in separate thread and returns its result."""
8080 loop = future .get_loop ()
8181
82- try :
83- result = function (* args , ** kwargs )
84- except BaseException as error :
85- error .traceback = format_exc ()
86- loop .call_soon_threadsafe (future .set_exception , error )
82+ result = execute (function , * args , ** kwargs )
83+
84+ if result .status == SUCCESS :
85+ loop .call_soon_threadsafe (future .set_result , result .value )
8786 else :
88- loop .call_soon_threadsafe (future .set_result , result )
87+ loop .call_soon_threadsafe (future .set_exception , result . value )
8988
9089
9190def _validate_parameters (name : str , daemon : bool ):
You can’t perform that action at this time.
0 commit comments