Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Nov 4, 2024
1 parent d12fcec commit 035e956
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cashu/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ def _is_lock_exception(e):
session: AsyncSession = self.async_session() # type: ignore
try:
logger.trace(f"Connecting to database trial: {trial} ({random_int})")
async with session.begin() as txn: # type: ignore
async with session.begin(): # type: ignore
logger.trace("Connected to database. Starting transaction")
wconn = Connection(session, txn, self.type, self.name, self.schema)
wconn = Connection(session, None, self.type, self.name, self.schema)
if lock_table:
await self.acquire_lock(
wconn, lock_table, lock_select_statement
Expand All @@ -232,10 +232,7 @@ def _is_lock_exception(e):
finally:
logger.trace(f"Closing session trial: {trial} ({random_int})")
await session.close()
# if not inherited:
# logger.trace("Closing session")
# await session.close()
# self._connection = None

raise Exception(
f"failed to acquire database lock on {lock_table} after {timeout}s and {trial} trials ({random_int})"
)
Expand Down

0 comments on commit 035e956

Please sign in to comment.