如何抑制pymodbus asyncio的折旧警告

发布于 2025-01-21 04:26:47 字数 586 浏览 4 评论 0原文

我们正在使用仍然使用旧的@asyncio.coroutine装饰器的第三方库,并正在生成有关导入的警告。我认识到这将在未来版本的Python中破坏。但是目前,我们只想关闭此警告,以免用户垃圾邮件。

我已经尝试了我能想到的一切来使这个沉默的一切,包括每个答案,甚至关闭所有折旧警告:

warnings.filterwarnings("ignore", category=DeprecationWarning)

from pymodbus.client.asynchronous.async_io import (
    BaseModbusAsyncClientProtocol,
    ReconnectingAsyncioModbusTcpClient,
    ReconnectingAsyncioModbusTlsClient,
)

似乎没有任何东西使它保持沉默。

We're using a third party library which still uses the old @asyncio.coroutine decorator and is generating a bunch of warnings on import. I recognise this will break in future versions of python. But for now we just want to turn off this warning so that it doesn't spam the user.

I've tried everything I can think of to silence this including every answer here and even turning off all depreciation warnings:

warnings.filterwarnings("ignore", category=DeprecationWarning)

from pymodbus.client.asynchronous.async_io import (
    BaseModbusAsyncClientProtocol,
    ReconnectingAsyncioModbusTcpClient,
    ReconnectingAsyncioModbusTlsClient,
)

Nothing seems to silence it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文