Created
September 20, 2022 16:10
-
-
Save mturoci/91bb046f393a5a4d5ea48494ff42a20d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start the polling, wrap in future so that we can cancel it later. | |
q.client.future = asyncio.ensure_future(polling_function(q)) | |
# Future cancellation raises an error - use trycatch. | |
try: | |
# Wait until polling finished. | |
await q.client.future | |
q.page['meta'].dialog = None | |
q.page['meta'].notification_bar = ui.notification_bar( | |
name='success_notification', | |
text='Job done!', | |
type='success', | |
events=['dismissed'] | |
) | |
# Handle cancellation. | |
except asyncio.CancelledError: | |
q.page['meta'].dialog.items[0].progress.caption = 'Cancelled' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment