Skip to content

Commit 36426ac

Browse files
authored
Retry twice when inserting memeber
Docs: https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.HttpRequest-class.html#execute We consistently run into SSLEOFError after a period of idling. When manually retrying, the request seems to go through. This PR uses the `num_retries` argument to automatically retry on request failure.
1 parent c4797ba commit 36426ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/google_admin_sdk_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def __init__(self, logger=logging.getLogger(__name__)):
3636
def get_group(self, group_key: str):
3737
return self.service.groups().get(groupKey=group_key).execute()
3838

39-
def insert_member(self, group_key: str, email: str):
39+
def insert_member(self, group_key: str, email: str, num_retries: int = 2):
4040
try:
41-
self.service.members().insert(groupKey=group_key, body={"email": email}).execute()
41+
self.service.members().insert(groupKey=group_key, body={"email": email}).execute(num_retries=num_retries)
4242
except HttpError as e:
4343
if e.resp.status == 409:
4444
self.logger.warning(f"Member {email} already exists in group {group_key}. Ignoring.")

0 commit comments

Comments
 (0)