Skip to content

Commit

Permalink
retry connection if pymonetdbd is not ready yet
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskamphuis committed Jun 14, 2019
1 parent 682ec78 commit 4cb9b41
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/python/search_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
import string
from topic_reader import TopicReader
import time

class SearchCollection:

Expand Down Expand Up @@ -52,11 +53,19 @@ def getConnectionCursor(self):
print("CREATE DATABASE")
dbname = 'robust04'

print("CREATE CONNECTION")
connection = pymonetdb.connect(username='monetdb',
password='monetdb',
hostname='localhost',
database=dbname)
connection = None
attempt = 0
while connection is None or attempt > 20:
print("CREATE CONNECTION")
try:
connection = pymonetdb.connect(username='monetdb',
password='monetdb',
hostname='localhost',
database=dbname)
except:
attempt += 1
time.sleep(5)

cursor = connection.cursor()
return cursor

Expand Down

0 comments on commit 4cb9b41

Please sign in to comment.