From 5364cf90044aa6e356f5627428d41814797569c1 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sun, 25 Mar 2018 21:26:53 +0000 Subject: [PATCH] Keep trying until session obtained --- discordbot/titanembeds/database/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discordbot/titanembeds/database/__init__.py b/discordbot/titanembeds/database/__init__.py index e2f3f6c..f9cc2e5 100644 --- a/discordbot/titanembeds/database/__init__.py +++ b/discordbot/titanembeds/database/__init__.py @@ -33,7 +33,12 @@ class DatabaseInterface(object): @contextmanager def get_session(self) -> Session: - session = self._sessionmaker() # type: Session + session = None + while session == None: + try: + session = self._sessionmaker() # type: Session + except: + pass try: yield session session.commit()