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

fix(fcm): A workaround for the concurrency issues in googleapiclient #558

Merged
merged 2 commits into from
Jun 25, 2021

Conversation

hiranya911
Copy link
Contributor

This is a possible solution to the problem outlined in #507. I wasn't quite able to repro the exception in the bug report, but the threading issues in googleapiclient are well known, and I can easily reproduce some concurrency issues by calling send_all() from just 3-4 parallel threads. The proposed solution is to instantiate a new transport instance for each invocation of send_all() (as opposed to using a shared transport across calls), and tests indeed confirm that it resolves the issues I managed to reproduce.

Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a new transport makes sense to me. Thanks!

@@ -373,10 +373,11 @@ def batch_callback(_, response, error):

batch = http.BatchHttpRequest(
callback=batch_callback, batch_uri=_MessagingService.FCM_BATCH_URL)
transport = self._build_transport(self._credential)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the reason to use _build_trasnport here (instead of directly using _auth.authorized_http) so we can write tests easily?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@hiranya911 hiranya911 merged commit 9ff16bd into master Jun 25, 2021
@hiranya911 hiranya911 deleted the hkj-mt-fix branch June 25, 2021 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants