I'm very new to multi-threading. I have 2 functions in my python script. One function enqueue_tasks
iterates through a large list of small items and performs a task on each item which involves appending an item to a list (lets call it master_list
). This I already have multi-threaded using futures.
executor = concurrent.futures.ThreadPoolExecutor(15) # Arbitrarily 15
futures = [executor.submit(enqueue_tasks, group) for group in grouper(key_list, 50)]
concurrent.futures.wait(futures)
I have another function process_master
that iterates through the master_list
above and checks the status of each item in the list, then does some operation.
Can I use the same method above to use multi-threading for process_master
? Furthermore, can I have it running at the same time as enqueue_tasks
? What are the implications of this? process_master
is dependent on the list from enqueue_tasks
, so will running them at the same time be a problem? Is there a way I can delay the second function a bit? (using time.sleep
perhaps)?