Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure timer runs awaitable #1098

Merged
merged 2 commits into from
Jun 28, 2023
Merged

Ensure timer runs awaitable #1098

merged 2 commits into from
Jun 28, 2023

Conversation

rodja
Copy link
Member

@rodja rodja commented Jun 28, 2023

The code

async def update_user():
    await asyncio.sleep(1)

ui.timer(1, lambda: update_user())

Produces the warning Enable tracemalloc to get traceback where the object was allocated.. While the reproduction is a bit artificial, it is beneficial to define lambda statements which return an awaitable because it simplifies passing parameters. We did something similar for button click handlers. This PR adds the same behaviour to ui.timer.

@rodja rodja added the enhancement New feature or request label Jun 28, 2023
@rodja rodja added this to the 1.2.24 milestone Jun 28, 2023
@falkoschindler falkoschindler merged commit b8033bd into main Jun 28, 2023
5 of 6 checks passed
@falkoschindler falkoschindler deleted the timer_with_awaitable branch June 28, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants