fix(proxy/utils.py): don't keep connecting to db if connection already established

This commit is contained in:
Krrish Dholakia 2024-01-03 17:43:44 +05:30
parent 4094356d6f
commit e898f3e49c
2 changed files with 7 additions and 3 deletions

View file

@ -255,7 +255,7 @@ class PrismaClient:
)
## init logging object
self.proxy_logging_obj = proxy_logging_obj
self.connected = False
os.environ["DATABASE_URL"] = database_url
# Save the current working directory
original_dir = os.getcwd()
@ -505,7 +505,11 @@ class PrismaClient:
)
async def connect(self):
try:
await self.db.connect()
if self.connected == False:
await self.db.connect()
self.connected = True
else:
return
except Exception as e:
asyncio.create_task(
self.proxy_logging_obj.failure_handler(original_exception=e)