20
Comment obtenir la valeur de retour d'un thread en python?
La fonction fooci-dessous renvoie une chaîne 'foo'. Comment puis-je obtenir la valeur 'foo'renvoyée par la cible du 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() La "façon évidente de le faire", illustrée ci-dessus, ne fonctionne pas: thread.join()retournée None.
342
python
multithreading