adding try inside the loop so it doesnt quit

This commit is contained in:
Lucas Oskorep
2022-06-23 01:39:43 -04:00
parent befc5f9f81
commit 6c0859e072
+7 -6
View File
@@ -28,9 +28,10 @@ class CalGrab(object):
:param time_to_update: normally set to -1 aka no limit. Time in minutes to continually ping the api for. :param time_to_update: normally set to -1 aka no limit. Time in minutes to continually ping the api for.
:return: None :return: None
""" """
try: start = None
start = None while True:
while True:
try:
now = datetime.utcnow() # 'Z' indicates UTC time now = datetime.utcnow() # 'Z' indicates UTC time
if start == None: if start == None:
start = now start = now
@@ -46,7 +47,7 @@ class CalGrab(object):
print('No upcoming events found.') print('No upcoming events found.')
return return
events = [i for i in [Event.get_from_gcal_api_json(json) for json in events] if i is not None] events = [i for i in [Event.get_from_gcal_api_json(json) for json in events] if i is not None]
print(events) print(events)
for callback in self.callbacks: for callback in self.callbacks:
@@ -54,5 +55,5 @@ class CalGrab(object):
if time_to_update > 0 and (now - start).total_seconds() > time_to_update: if time_to_update > 0 and (now - start).total_seconds() > time_to_update:
return return
sleep(frequency) sleep(frequency)
except HttpError as error: except HttpError as error:
print('An error occurred: %s' % error) print('An error occurred: %s' % error)