in provider/database.py [0:0]
def createCanary(self):
maxRetries = 3
retryCount = 0
while retryCount < maxRetries:
try:
if self.canaryId in self.database.keys(remote=True):
# update the timestamp to cause a document change
logging.debug("[database] Canary doc exists, updating it.")
myCanaryDocument = self.database[self.canaryId]
myCanaryDocument["canary-timestamp"] = datetime.now().isoformat()
myCanaryDocument.save()
return
else:
# create the canary doc for this instance
logging.debug("[database] Canary doc does not exist, creating it.")
document = dict()
document['_id'] = self.canaryId
document['canary-timestamp'] = datetime.now().isoformat()
result = self.database.create_document(document)
logging.debug('[canary] Successfully wrote canary to DB')
return
except Exception as e:
retryCount += 1
logging.error(
'[canary] Uncaught exception while writing canary document: {}'.format(e))
logging.error('[canary] Retried and failed {} times to create a canary'.format(maxRetries))