Skip to content

Connection lost issue when calling long running function #3115

Answered by falkoschindler
megarg asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry, I should have mentioned the import:

from nicegui import background_tasks

Oh and I forgot to copy&paste the run_in_executor line which actually calls sync_func. I updated my code above.

Yes, ui.timer is also a common method to trigger a background task. But make sure to set once=True to avoid repeating the task every 1 second:

ui.timer(0, load_data, once=True)

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@megarg
Comment options

@falkoschindler
Comment options

@megarg
Comment options

@falkoschindler
Comment options

Answer selected by megarg
@megarg
Comment options

@falkoschindler
Comment options

Comment options

You must be logged in to vote
1 reply
@evnchn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants