Skip to content

Commit

Permalink
fix: break loop after expected conditions have been met
Browse files Browse the repository at this point in the history
Close issue #19
  • Loading branch information
César Román committed Aug 5, 2021
1 parent 04bb5a6 commit 9f0c0e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/incendium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
__author_email__ = "[email protected]"
__license__ = "MIT"
__url__ = "https://github.com/thecesrom/incendium"
__version__ = "1.0.5"
__version__ = "1.0.6"
8 changes: 8 additions & 0 deletions src/incendium/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,20 @@ def __enter__(self):

for _ in range(self.retries):
Thread.sleep(1000)
if self.status == "Valid":
break
if self.status == "Faulted":
raise IOError(
"The database connection {!r} is {}.".format(
self.database, self.status
)
)
else:
raise IOError(
"The database connection {!r} could not be enabled.".format(
self.database
)
)
return self

def __exit__(self, exc_type, exc_val, exc_tb):
Expand Down

0 comments on commit 9f0c0e7

Please sign in to comment.