python - 等待 asyncio.sleep ('dict' 对象不可调用中的类型错误)

标签 python python-3.x typeerror python-asyncio aiohttp

我最近开始使用 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

https://youtrack.jetbrains.com/issue/PY-25856

关于python - 等待 asyncio.sleep ('dict' 对象不可调用中的类型错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54289895/

相关文章:

mysqldb 上的 Python 多处理

python - 如何在 Python 中生成指数增长的范围

python-3.x - 如何在 tkinter 中使用 gridlayout 创建扩展 PanedWindow?

Python参数范围-相同的对象?

python - 使用 urllib2 进行 SOAP POST,但我不断收到错误

python - 链接的 HTTP 选择器(xpath 或 css)

python - 如何按 Pandas 中的值对系列进行分组?

python - 如何将字符串转换为二进制?

javascript - 无法摆脱这种类型的错误

javascript - 未捕获的类型错误 : lang is not a function