Sto tentando di utilizzare una coda multithreading e una coda di multiprocessing allo stesso tempo. La coda di threading verrà utilizzata da 20 thread per recuperare molte pagine Web. Quindi voglio mettere le pagine in una coda multiprocesso in modo che 4 processisti possano eseguire il crunch dei dati. Di seguito è la mia struttura di base. Il mio problema è che, la coda di lavoro, dà un errore dicendo che Coda non è iterabile. Penso che la coda del multithreading stia sovrascrivendo la coda multiprocesso ma non so davvero cosa c'è che non va.Utilizzo di thread e processi insieme alle code condivise in Python
ticker_queue = Queue()
work_queue = Queue()
tickers = get_tickers()
for i in tickers:
ticker_queue.put(i)
for i in range(20):
t = Thread(target=network_worker, args = (ticker_queue, work_queue)).start()
for i in range(4):
p = Process(target = worker, args = (work_queue)).start()
Ecco la traceback
Traceback (most recent call last):
File "OneDrive\Python\andys.py", line 108, in <module>
p = Process(target = worker, args = (work_queue)).start()
File "C:\Python27\lib\multiprocessing\process.py", line 104, in __init__
self._args = tuple(args)
TypeError: 'Queue' object is not iterable
bollire il problema in un semplice esempio autonomo, quindi pubblicare l'esempio e il traceback. Nessuno ha visto il professor Xavier per un po '.. ;-) – thebjorn
Devo andare a lavorare in pochi, posterò un esempio autonomo più tardi stasera se nessuno ha risposto. Grazie. – mobone
Manca una virgola: 'p = Processo (target = worker, args = (work_queue,)). Start()' – thebjorn