python
runtime_error
ai_generated
true
运行时错误:锁未获取
RuntimeError: Lock is not acquired
ID: python/asyncio-lock-not-acquired
80%修复率
88%置信度
0证据数
2025-06-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.7 | active | — | — | — |
| 3.8 | active | — | — | — |
根因分析
在未持有的asyncio.Lock上调用lock.release()。
English
Calling lock.release() on an asyncio.Lock that is not currently held.
解决方案
-
100% 成功率
async with lock: ...
-
95% 成功率
await lock.acquire(); try: ... finally: lock.release()
无效尝试
常见但无效的做法:
-
90% 失败
acquire() is a coroutine; must be awaited.
-
70% 失败
It's a race condition; the lock may be released between check and release.