Setup: Python 3.7.4
I am trying to create 6 sockets using asyncio listening on different ports. I tried to implement it like this.
Code:
import asyn
Rewrite your enable_sockets function like this:
enable_sockets
def enable_sockets(): try: host = '127.0.0.1' port = 60000 sockets_number = 6 loop = asyncio.get_event_loop() for i in range(sockets_number): loop.create_task(start_servers(host,port+i)) loop.run_forever() except Exception as exc: print(exc)