Skip to content

Commit d21c512

Browse files
authored
fix silent error in run_task (#2959)
* fix silent error in run_task * fix
1 parent 36b0198 commit d21c512

File tree

1 file changed

+12
-1
lines changed
  • sdk/python/packages/flet-core/src/flet_core

1 file changed

+12
-1
lines changed

sdk/python/packages/flet-core/src/flet_core/page.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,18 @@ def __on_page_change_event(self, data):
495495

496496
def run_task(self, handler: Callable[..., Awaitable[Any]], *args, **kwargs):
497497
assert asyncio.iscoroutinefunction(handler)
498-
return asyncio.run_coroutine_threadsafe(handler(*args, **kwargs), self.__loop)
498+
499+
future = asyncio.run_coroutine_threadsafe(handler(*args, **kwargs), self.__loop)
500+
501+
def _on_completion(f):
502+
exception = f.exception()
503+
504+
if exception:
505+
raise exception
506+
507+
future.add_done_callback(_on_completion)
508+
509+
return future
499510

500511
def run_thread(self, handler, *args):
501512
if is_pyodide():

0 commit comments

Comments
 (0)