Skip to content

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

Merged
hiranya911 merged 2 commits into
masterfrom
hkj-mt-fix
Jun 25, 2021
Merged

hiranya911 merged 2 commits into
masterfrom
hkj-mt-fix

Conversation

@hiranya911

Copy link
Copy Markdown
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.

@lahirumaramba lahirumaramba left a comment

Copy link
Copy Markdown
Member

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!


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

Copy link
Copy Markdown
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
Copy Markdown
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