I have a program that uses python threads like this: starting 5 threads and start processing a list of elements.
def process_element(element):
print(element)
jobs = Queue()
def do_stuff(q):
while not q.empty():
value = q.get()
process_element(element=value)
q.task_done()
for i in line: # my list of element
jobs.put(i)
for i in range(5):
worker = threading.Thread(target=do_stuff, args=(jobs))
worker.start()
jobs.join()
How can I use asyncio to do the same work.