【发布时间】:2020-01-01 20:28:44
【问题描述】:
这个线程中的 aiohttp 服务器示例失败并出现RuntimeError: There is no current event loop in thread 'Thread-1'. 错误:
import threading
from aiohttp import web
def aiohttp_server():
def say_hello(request):
return web.Response(text='Hello, world')
app = web.Application(debug=True)
app.add_routes([web.get('/', say_hello)])
web.run_app(app)
t = threading.Thread(target=aiohttp_server)
t.start()
如何在线程中运行aiohttp服务器?
【问题讨论】:
-
也许这个例子会对你有所帮助:stackoverflow.com/questions/54650760/…
标签: python python-asyncio aiohttp