-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve async compatibility of app store #177
base: main
Are you sure you want to change the base?
Conversation
This moves some code from the background task to the main task, and refactors it to allow use of async methods. This looks like these tasks were in background from the idea that the background task runs 'in the background', rather than runs 'when the app is in the background'. There are two calls that use requests.get, which block the update task. By refactoring slightly to use async, we can use async_helpers.unblock to move them to a thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't test this right now but I think there's one issue?
get, render_update, APP_STORE_LISTING_URL | ||
) | ||
except Exception: | ||
self.update_state("no_index") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would get changed in the next line wouldn't it
try: | ||
self.response = await async_helpers.unblock( | ||
get, render_update, APP_STORE_LISTING_URL | ||
) | ||
except Exception: | ||
self.update_state("no_index") | ||
self.update_state("index_received") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, per Naomi's comment I think this ought to be like this?
try: | |
self.response = await async_helpers.unblock( | |
get, render_update, APP_STORE_LISTING_URL | |
) | |
except Exception: | |
self.update_state("no_index") | |
self.update_state("index_received") | |
try: | |
self.response = await async_helpers.unblock( | |
get, render_update, APP_STORE_LISTING_URL | |
) | |
self.update_state("index_received") | |
except Exception: | |
self.update_state("no_index") |
This moves some code from the background task to the main task, and refactors it to allow use of async methods. This looks like these tasks were in background from the idea that the background task runs 'in the background', rather than runs 'when the app is in the background'.
There are two calls that use requests.get, which block the update task. By refactoring slightly to use async, we can use async_helpers.unblock to move them to a thread.