我试图在Python 3.6
上的sanic
应用程序中使用async raw socket
并且对来自curio
的异步函数在sanic异步上下文中不起作用感到非常惊讶。最小概念证明:
import curio
from sanic import Sanic
from sanic.response import text
app = Sanic(__name__)
@app.route('/')
async def index(request):
sock = await curio.open_connection("google.com", 443, ssl=True)
resp = await sock.recv(1024)
return text(resp)
app.run(host="0.0.0.0", port=5001)
此代码在任何http请求上生成核心转储
^{pr2}$
为了将这个问题与github问题联系起来,OP
Using curio in sanic controller。在
总结(来自问题评论):
相关问题 更多 >
编程相关推荐