J
J
Jungles2020-07-28 15:31:34
Python
Jungles, 2020-07-28 15:31:34

Multiprocessing module object not iterable?

spoiler
import multiprocessing as mp

def washer(dishes, output):
    for dish in dishes:
        print('Washing ' ,dish, 'dish')
        output.put(dish)

def dryer(input):
    while True:
        dish = input.get()
        print('Drying ', dish , 'dish')
        input.task_done()

dish_queue = mp.JoinableQueue()
dryer_proc = mp.Process(target = dryer , args = (dish_queue,))
dryer_proc.daemon = True
dryer_proc.start()
dishes = ['salad' ,'soup', 'bread' ,' entree']
washer(dishes,dish_queue)
dish_queue.join()

Why is it that if you remove the comma here args = (dish_queue,)), which seems to be correct, an error will be raised?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-07-28
@Jungles

(dish_queue,) is a one element tuple and
(dish_queue) is the same as dish_queue

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question