File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from traceback import format_exc
2020from concurrent .futures import Future
2121
22- from pebble .common import launch_thread , SUCCESS
22+ from pebble .common import execute , launch_thread , SUCCESS
2323
2424
2525def thread (* args , ** kwargs ) -> Callable :
@@ -77,13 +77,12 @@ def _function_handler(
7777 """Runs the actual function in separate thread and returns its result."""
7878 future .set_running_or_notify_cancel ()
7979
80- try :
81- result = function (* args , ** kwargs )
82- except BaseException as error :
83- error .traceback = format_exc ()
84- future .set_exception (error )
80+ result = execute (function , * args , ** kwargs )
81+
82+ if result .status == SUCCESS :
83+ future .set_result (result .value )
8584 else :
86- future .set_result (result )
85+ future .set_exception (result . value )
8786
8887
8988def _validate_parameters (name : str , daemon : bool ):
You can’t perform that action at this time.
0 commit comments