20
Come ottenere il valore restituito da un thread in Python?
La funzione fooseguente restituisce una stringa 'foo'. Come posso ottenere il valore 'foo'che viene restituito dalla destinazione del thread? from threading import Thread def foo(bar): print('hello {}'.format(bar)) return 'foo' thread = Thread(target=foo, args=('world!',)) thread.start() return_value = thread.join() "Un modo ovvio per farlo", mostrato sopra, non funziona: thread.join()restituito None.
342
python
multithreading