1
如何從1個Python程序運行許多aiohttp服務器 例子:如何運行從Python程序很多aiohttp服務器
manager = Manager()
server1 = manager.create_server(config1)
server2 = manager.create_server(config2)
server1.run() # here program stop
server2.run() # but i want to run these two servers at the same time
我想使用threading.Thread(),使許多線程和運行的服務器有 但得到這個錯誤:
RuntimeError: There is no current event loop in thread 'thname'
我嘗試用戶loop.run_in_executor(),但這種方式沒有任何反應, 程序完成沒有錯誤,服務器無法運行。
這是服務器運行功能
def run(self, port, host):
app = web.Application()
app.router.add_post('/', self._get_update)
web.run_app(app, host=host, port=port)
https://stackoverflow.com/questions/44850701/multiple-aiohttp-applications-running-in-the-same-process – Juggernaut