什么是“执行<句柄< TaskWakeupMethWrapper ..."? python asyncio中的警告意思是 [英] What does an "Executing <Handle <TaskWakeupMethWrapper..." warning in python asyncio mean

查看:308
本文介绍了什么是“执行<句柄< TaskWakeupMethWrapper ..."? python asyncio中的警告意思是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设置异步将来的结果时,下面的消息正在打印.

The message below is being printed while setting the result of an asyncio future.

Executing <Handle <TaskWakeupMethWrapper object at 0x7fc3435141f8>(<Future finis...ection.py:260>) created at /media/stuff/stuff/projects/dare/dcds/dcds/common/connection.py:221> took 1.723 seconds

我什至不知道从哪里开始寻找原因.但是,如果我关闭了异步调试模式,它将崩溃并向我显示.

I have no idea where even to start looking for the cause. But if I turn off the asyncio debug mode it crashes and shows me this.

Task was destroyed but it is pending!
task: <Task pending coro=<upload.<locals>.upload_coro() done, defined at /media/stuff/stuff/projects/dare/dcds/dcds/__main__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fdf5df01d38>()]> cb=[_chain_future.<locals>._call_set_state() at /home/elviento/anaconda3/lib/python3.6/asyncio/futures.py:414]>

推荐答案

Executing <Handle <TaskWakeupMethWrapper object at 0x7fc3435141f8>(<Future finis...ection.py:260>) created at /media/stuff/stuff/projects/dare/dcds/dcds/common/connection.py:221> took 1.723 seconds

此警告的主要部分是took 1.723 seconds:警告表示某些协程(或任务)已将事件循环冻结了1.7秒,这是不正常的情况(如果您不明白原因,请阅读答案此处或更好的此处 ).

Main part of this warning is took 1.723 seconds: warning says that some coroutine (or task) has freezed your event loop for 1.7 seconds, which is not normal situation (if you don't see why, please read answer here or better here).

如您所述,异步仅在调试模式打开时跟踪此问题.

As you noted asyncio tracks this problem only when debug mode is on.

Task was destroyed but it is pending!

无论调试模式如何,都会收到此警告,这意味着在调用loop.close()时,您仍在运行任务.还是不正常的情况(请在此处了解原因).

This warning you'll get regardless of debug mode, it means that at the moment you call loop.close() you still have running tasks. It's again not normal situation (read here to see why).

如果没有可重复的代码段,很难说更多.

It's hard to say more without reproducible code snippet.

如果将任务存储在WeakValueDictionary中,可能会出现问题,是的.在关闭事件循环之前,您应该正确取消所有任务(或等待它们完成).

If you store task in WeakValueDictionary it can be problem, yes. You should properly cancel all tasks (or await them to be finished) before you close event loop.

这篇关于什么是“执行&lt;句柄&lt; TaskWakeupMethWrapper ..."? python asyncio中的警告意思是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆