You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2017/07/10 15:24:03 UTC
[incubator-openwhisk-package-kafka] branch master updated: Fix
infinite loop in error handling (#194)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-kafka.git
The following commit(s) were added to refs/heads/master by this push:
new 5069ea1 Fix infinite loop in error handling (#194)
5069ea1 is described below
commit 5069ea193183cb6da2f33c0037d57f791d052434
Author: Justin Berstler <bj...@us.ibm.com>
AuthorDate: Mon Jul 10 11:24:01 2017 -0400
Fix infinite loop in error handling (#194)
Due to a logic error, the retry loop for creating a canary would loop infinitely after retryCount got to 0. Fix this erorr to ensure that the loop will exit after the specified number of retries.
---
provider/database.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/provider/database.py b/provider/database.py
index 095a779..0d2e3b6 100644
--- a/provider/database.py
+++ b/provider/database.py
@@ -80,23 +80,23 @@ class Database:
return self.database.infinite_changes(include_docs=True, heartbeat=(timeout*1000), since=since)
def createCanary(self):
- retryCount = 3
+ maxRetries = 3
+ retryCount = 0
- while retryCount >= 0:
- if retryCount == 0:
- logging.error('[canary] Retried and failed {} times to create a canary'.format(retryCount))
- else:
- try:
- document = dict()
- document['canary'] = datetime.now().isoformat()
+ while retryCount < maxRetries:
+ try:
+ document = dict()
+ document['canary'] = datetime.now().isoformat()
+
+ result = self.database.create_document(document)
+ logging.info('[canary] Successfully wrote canary to DB')
- result = self.database.create_document(document)
- logging.info('[canary] Successfully wrote canary to DB')
+ return result
+ except Exception as e:
+ retryCount += 1
+ logging.error('[canary] Uncaught exception while recording trigger to database: {}'.format(e))
- return result
- except Exception as e:
- retryCount -= 1
- logging.error('[canary] Uncaught exception while recording trigger to database: {}'.format(e))
+ logging.error('[canary] Retried and failed {} times to create a canary'.format(maxRetries))
def deleteDoc(self, docId):
try:
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].