implement multi-threading on python code

Job ID: 36140458

Budget: $10 – $50 USD

Following code works with only 1 ip address of the tcp connector. I want to implement multi-threading on it so multiple & random IP addresses run it for 100-1000 ips. Running should be fast.

-------
CODE
-------
import aiohttp
import asyncio
import time
import socket

start_time = time.time()
async def main():
connector = aiohttp.TCPConnector(local_addr=('2a05:4e0::1', 0), family=socket.AF_INET6)
async with aiohttp.ClientSession(connector=connector) as session:
tasks = []
for x in range(5):
task = asyncio.ensure_future(fetch(session, x))
tasks.append(task)

response = await asyncio.gather(*tasks)

print(response)
async def fetch(session, x):
url = f'http://ipv6.google.com/'

async with session.get(url) as response:
result_data = await response.text()
return x

asyncio.run(main())

print("--- %s seconds ---" % (time.time() - start_time))


---------NOTE----------
I can provide server SSH with 100 ips for testing.
Related categories: Python Socket IO