Duplicate Check
Describe the bug
The Page.create_task returns a Future object of concurrent.futures.Future type. This type of Future object is not awaitble.
As awaiting is often essential with asynchronous applications, it would be nice if the run_task could return an awaitable type, such as asyncio.Future or asyncio.Task.
It is possible to use Page.loop.create_future() or Page.loop.create_task() to get awaitable Task or Future objects, but somehow those do not seem to integrate with Flet event loop as well as Page.create_task, as sometimes the UI does not update as expected.
Code sample
Code
import flet as ft
async def main(page: ft.Page):
async def coro():
pass
# works
loop_create_task = page.loop.create_task(coro())
print("awaiting page.loop.create_task, type:", type(loop_create_task))
await loop_create_task
print("awaited successfully\n")
# works
loop_create_future = page.loop.create_future()
print("awaiting page.loop.create_future, type:", type(loop_create_future))
loop_create_future.set_result(None)
await loop_create_future
print("awaited successfully\n")
# fails
page_run_task = page.run_task(coro)
print("awaiting page.run_task, type:", type(page_run_task))
await page_run_task
print("awaited successfully\n")
ft.run(main)
To reproduce
- Create task with
Page.run_task
- Try to await the returned Future
Expected behavior
No response
Screenshots / Videos
No response
Operating System
Linux
Operating system details
Arch Linux
Flet version
0.85.1
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Additional details
No response
Duplicate Check
Describe the bug
The
Page.create_taskreturns a Future object of concurrent.futures.Future type. This type of Future object is not awaitble.As
awaiting is often essential with asynchronous applications, it would be nice if therun_taskcould return an awaitable type, such as asyncio.Future or asyncio.Task.It is possible to use
Page.loop.create_future()orPage.loop.create_task()to get awaitable Task or Future objects, but somehow those do not seem to integrate with Flet event loop as well asPage.create_task, as sometimes the UI does not update as expected.Code sample
Code
To reproduce
Page.run_taskExpected behavior
No response
Screenshots / Videos
No response
Operating System
Linux
Operating system details
Arch Linux
Flet version
0.85.1
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Additional details
No response