Python 如何确保找到一个等待asyncio.wait(…)的协同路由?

Python 如何确保找到一个等待asyncio.wait(…)的协同路由?,python,websocket,python-asyncio,twisted,web3py,Python,Websocket,Python Asyncio,Twisted,Web3py,考虑以下一对协程: import asyncio from twisted.internet.defer import ensureDeferred async def _something_that_does_io(): return b"A stream or buffer of some sort" async def public_interface(): await asyncio.wait(_something_that_does_io)

考虑以下一对协程:

import asyncio
from twisted.internet.defer import ensureDeferred

async def _something_that_does_io():
    return b"A stream or buffer of some sort"

async def public_interface():
    await asyncio.wait(_something_that_does_io)
    return "metadata and connection details"

d = ensureDeferred(public_interface())
在评估函数时,此处指定的
将导致
内置。RuntimeError:未引发运行事件循环

在我的例子中,真实世界的应用程序试图确保在
websockets
库中有一个来自
protocol.WebSocketCommonProtocol.recv
的延迟

web3
库使用
websockets
连接到提供者,我正在尝试创建一个简单的机制来添加和处理背压

添加诸如
reactor.callInThread(asyncio\u event\u loop.run\u ever)之类的内容是没有帮助的,因为它显然是特定于线程的


这里到底发生了什么?我怎样才能确保找到这样一个协同程序呢?

您是否尝试过推迟.fromFuture(asyncio.sure\u future(public\u interface())
?什么反应堆在运转?应该是。在
asyncio.wait()
中发生了一些粗略的情况。如果将其替换为
等待执行的操作()
,则不会出现错误。顺便说一句,亨德里克斯岩石!还值得注意的是,文档中有关于将协同程序与
asyncio.wait
一起使用的弃用说明。