fix(fcm): A workaround for the concurrency issues in googleapiclient by hiranya911 · Pull Request #558 · firebase/firebase-admin-python
Conversation
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.
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) |
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?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
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