How can i run many aiohttp servers from 1 python program Example:
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
I am trying to use threading.Thread() to make many threads and run servers there but get this error:
RuntimeError: There is no current event loop in thread 'thname'
I try to user loop.run_in_executor(), but in this way nothing happens, program finishes without errors and servers not run.
This is server run function
def run(self, port, host):
app = web.Application()
app.router.add_post('/', self._get_update)
web.run_app(app, host=host, port=port)
I found answer
First
So then we can do next
And all will be OK!