Concurrency
concurrency
KeyedLock
Per-key asyncio lock manager.
Provides a separate asyncio.Lock for each key, created lazily.
Concurrent operations on different keys proceed in parallel;
operations on the same key are serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float | None
|
Maximum seconds to wait for a lock.
|
_DEFAULT_TIMEOUT
|
Source code in packages/axm-mcp/src/axm_mcp/concurrency.py
__call__(key)
async
Acquire the lock for key, with optional timeout.
Idle entries are reaped opportunistically on release once no
coroutine holds or awaits the key, so the map stays bounded
under a long-running server without any external prune().
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If timeout is set and exceeded. |
Source code in packages/axm-mcp/src/axm_mcp/concurrency.py
__len__()
prune()
Remove idle entries (no holder, no waiter). Returns count removed.
Retained for compatibility: opportunistic reaping on release already bounds the map, so this is normally a no-op. An entry is idle only when unlocked and its reference count is zero — a held or awaited key is never removed.