Skip to content

Commit

Permalink
die after 30 retries
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Aug 15, 2010
1 parent efd9583 commit 57baf21
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bley.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,20 @@ def safe_execute(self, query, params=None):
except:
pass
self.db = None
while not self.db:
retries = 0
while not self.db and retries < 30:
try:
self.db = self.factory.settings.database.connect(**self.factory.settings.dbsettings)
self.dbc = self.db.cursor()
except self.factory.settings.database.OperationalError:
self.db = None
retries += 1
sleep(1)
self.dbc.execute(query, params)
if self.db:
self.dbc.execute(query, params)
else:
self.factory.settings.logger('Could not reconnect to the database, exiting.\n')
reactor.stop()

class BleyPolicyFactory(Factory):
protocol = BleyPolicy
Expand Down

0 comments on commit 57baf21

Please sign in to comment.