Skip to content

Commit

Permalink
fix silent error in run_task (#2959)
Browse files Browse the repository at this point in the history
* fix silent error in run_task

* fix
  • Loading branch information
50Bytes-dev authored Apr 3, 2024
1 parent 36b0198 commit d21c512
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sdk/python/packages/flet-core/src/flet_core/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,18 @@ def __on_page_change_event(self, data):

def run_task(self, handler: Callable[..., Awaitable[Any]], *args, **kwargs):
assert asyncio.iscoroutinefunction(handler)
return asyncio.run_coroutine_threadsafe(handler(*args, **kwargs), self.__loop)

future = asyncio.run_coroutine_threadsafe(handler(*args, **kwargs), self.__loop)

def _on_completion(f):
exception = f.exception()

if exception:
raise exception

future.add_done_callback(_on_completion)

return future

def run_thread(self, handler, *args):
if is_pyodide():
Expand Down

0 comments on commit d21c512

Please sign in to comment.