Skip to content

Correct pattern for async calls #236

Answered by jourdain
dieterrosch asked this question in Q&A
Discussion options

You must be logged in to vote

When you have async update of the state, you need to be explicit when you want that state to be updated.

The easier approach is to do state change in the state context like below:

async do_something():
    while True:
          await asyncio.sleep(0.5)
          with state:
               state.progress += 1

Otherwise you can call state.flush()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jourdain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants