我最近开始使用 python,并在我的 aiohttp
服务器上收到以下错误日志:
ERROR:app.handlers.socket_handler:'dict' object is not callable
Traceback (most recent call last):
File "[...]/app/handlers/socket_handler.py", line 47, in try_coroutine
await coroutine
File "[...]/app/handlers/socket_handler.py", line 65, in do_stuff
async for data in stuff_repo.observe_stuff(search=param_search):
File "[...]/app/repositories/stuff_repository.py", line 74, in observe_stuff
await asyncio.sleep(sleep_for)
TypeError: 'dict' object is not callable
这对我来说没有任何意义,因为 asyncio.sleep
中不涉及 dict
对象或 callable
对象调用,并且 sleep_for
是一个值为 30 的 int,因此不会被修改,仅读取:
代码可能有什么问题?
最佳答案
这是一个 PyCharm 错误,因为它仅在已经调试时添加断点时引起。
修复:
添加环境变量PYDEVD_USE_FRAME_EVAL=NO
来源:
Debugging asyncio code in PyCharm causes absolutely crazy unrepeatable errors
关于python - 等待 asyncio.sleep ('dict' 对象不可调用中的类型错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54289895/