Skip to content

Commit

Permalink
🧪 Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ff137 committed Feb 12, 2025
1 parent c51cae8 commit faa24e9
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions acapy_agent/ledger/indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ def __init__(
"""Private constructor. Use 'create_instance' to instantiate."""
LOGGER.debug(
"Initializing IndyVdrLedgerPool with name: %s, keepalive: %s, "
"cache_duration: %s, read_only: %s\nTraceback:\n%s",
"cache_duration: %s, read_only: %s",
name,
keepalive,
cache_duration,
read_only,
"".join(traceback.format_stack(limit=5)[:-1]),
)

# Instance attributes
Expand Down Expand Up @@ -150,12 +149,12 @@ async def get_or_create(
"""
LOGGER.debug(
"Creating or retrieving IndyVdrLedgerPool instance with params: name=%s, "
"keepalive=%s, cache_duration=%s, read_only=%s, socks_proxy=%s",
"keepalive=%s, cache_duration=%s, read_only=%s\nTraceback:\n%s",
name,
keepalive,
cache_duration,
read_only,
socks_proxy,
"".join(traceback.format_stack(limit=5)),
)

config_key = (name, keepalive, cache_duration, read_only, socks_proxy)
Expand Down Expand Up @@ -409,6 +408,11 @@ async def close(self):
"Failed to close pool ledger after 3 attempts", exc_info=exc
)
self.ref_count += 1 # if we are here, we should have self.ref_lock
LOGGER.debug(
"Re-incremented reference count to %s for instance %s",
self.ref_count,
self.name,
)
self.close_task = None
raise LedgerError("Exception when closing pool ledger") from exc

Expand All @@ -421,14 +425,15 @@ async def context_open(self):
LOGGER.debug("Opening the pool ledger")
await self.open()
self.ref_count += 1
LOGGER.debug(
"In context_open: Incremented reference count to %s for instance %s",
self.ref_count,
self.name,
)

async def context_close(self):
"""Release the reference and schedule closing of the pool ledger."""
LOGGER.debug(
"Context close called for pool %s\nTraceback:\n%s",
self.name,
"".join(traceback.format_stack(limit=5)[:-1]),
)
LOGGER.debug("Context close called for pool %s", self.name)

async def closer(timeout: int):
"""Close the pool ledger after a timeout."""
Expand Down Expand Up @@ -525,12 +530,20 @@ async def __aenter__(self) -> "IndyVdrLedger":
The current instance
"""
LOGGER.debug(
"Entering IndyVdrLedger context manager\nTraceback:\n%s",
"".join(traceback.format_stack(limit=5)),
)
await super().__aenter__()
await self.pool.context_open()
return self

async def __aexit__(self, exc_type, exc, tb):
"""Context manager exit."""
LOGGER.debug(
"Exiting IndyVdrLedger context manager\nTraceback:\n%s",
"".join(traceback.format_stack(limit=5)),
)
await self.pool.context_close()
await super().__aexit__(exc_type, exc, tb)

Expand Down

0 comments on commit faa24e9

Please sign in to comment.