运行时警告:启用tracemalloc以获取对象分配traceb

2024-05-21 05:48:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我读了木星教程Index

试过了

In [15]: print('before sleep'); sleep(12); print('after sleep')
before sleep
/home/me/anaconda3/bin/ipython:1: RuntimeWarning: coroutine 'sleep' was never awaited
  #!/home/me/anaconda3/bin/python
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
after sleep

对警告很困惑


Tags: inhomeindexbinipython教程sleep木星
1条回答
网友
1楼 · 发布于 2024-05-21 05:48:52

这个错误意味着函数(实际上是一个协程)“sleep”从未执行过。在

尝试将其替换为:

asyncio.get_event_loop().run_until_complete(sleep(25))

否则,只需使用非异步睡眠方法:

^{pr2}$

祝你好运!在

相关问题 更多 >