![](/img/trans.png)
[英]RuntimeWarning: Enable tracemalloc to get the object allocation traceback with asyncio.sleep
[英]RuntimeWarning: Enable tracemalloc to get the object allocation traceback
我讀了Jupiter教程索引
並嘗試過
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
對警告很困惑,
此錯誤意味着函數(實際上是協程)“睡眠”從未執行過。
嘗試將其替換為:
asyncio.get_event_loop().run_until_complete(sleep(25))
否則,只需使用非異步睡眠方法:
import time
time.sleep(25)
祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.