简体   繁体   中英

RuntimeWarning: Enable tracemalloc to get the object allocation traceback

I read the Jupiter tutorial Index

and tried

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

Very confused about the warning,

This error means that the function (actually a coroutine) "sleep" was never executed.

Try to replace it with:

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

Otherwise, just use a non-asynchronous sleep method:

import time
time.sleep(25)

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM