I have the following code.
def foos(n):
sleep(0.5)
yield n
k = 8
futures = []
with ThreadPoolExecutor(10) as exc:
for i in range(k):
futures.append(exc.submit(foos, i))
for future in as_completed(futures):
result = future.result()
for v in result:
print(v)
This code currently prints sequentially with an interval of 0.5 secs. How do i concurrently pull the results?