Skip to content

Commit

Permalink
Merge branch 'fix/retry-with-backoff' into new-main
Browse files Browse the repository at this point in the history
  • Loading branch information
kaeff committed Sep 1, 2021
2 parents dee0ef0 + c667ee7 commit 5c79011
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

COPIED_EVENT_LEADING_TEXT = '[CLIENT MEETING]'

NUM_RETRIES = 10

class Calendar:
def __init__(self, calendarId, googleService):
Expand All @@ -23,7 +24,7 @@ def copyAllEventsFrom(self, otherCalendar, period: DatePeriod, copySensibleData,
def getEvents(self, period: DatePeriod):
events_result = self.googleService.events().list(calendarId=self.calendarId, timeMin=period.start,
timeMax=period.end, singleEvents=True,
orderBy='startTime').execute()
orderBy='startTime').execute(num_retries=NUM_RETRIES)
events = events_result.get('items', [])
return events

Expand All @@ -34,7 +35,7 @@ def removeCopiedEvents(self, period: DatePeriod):
self.deleteEvent(event.get("id"))

def deleteEvent(self, eventId):
self.googleService.events().delete(calendarId=self.calendarId, eventId=eventId).execute()
self.googleService.events().delete(calendarId=self.calendarId, eventId=eventId).execute(num_retries=NUM_RETRIES)

def createEventFrom(self, sourceEvent, copySensibleData, colorId):
eventBody = {
Expand All @@ -52,7 +53,7 @@ def createEventFrom(self, sourceEvent, copySensibleData, colorId):
if colorId:
eventBody['colorId'] = colorId

createdEvent = self.googleService.events().insert(calendarId=self.calendarId, body=eventBody).execute()
createdEvent = self.googleService.events().insert(calendarId=self.calendarId, body=eventBody).execute(num_retries=NUM_RETRIES)

return createdEvent

Expand Down

0 comments on commit 5c79011

Please sign in to comment.