Skip to content

Commit 16210b7

Browse files
committed
concurrent: use common.execute to run the function
Signed-off-by: Matteo Cafasso <[email protected]>
1 parent fd2c952 commit 16210b7

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

pebble/concurrent/thread.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from traceback import format_exc
2020
from concurrent.futures import Future
2121

22-
from pebble.common import launch_thread, SUCCESS
22+
from pebble.common import execute, launch_thread, SUCCESS
2323

2424

2525
def 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

8988
def _validate_parameters(name: str, daemon: bool):

0 commit comments

Comments
 (0)