0

Let's so I have the following to requests urls in parallel:

 def _target(url):
     res = requests.get(url)
     print (res)
     return res

 while True:
     threads = [threading.Thread(target=_target, args=(url,)) for url in urls]
     [thread.start() for thread in threads]
     [thread.join() for thread in threads]

How can I read the output from the threads array? Or, is it not possible directly, and I need to use something like a global variable or write to some form of shared file/memory/etc. ? What would be the proper way to do the above?

samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
  • Does this answer your question? [How to get the return value from a thread in python?](https://stackoverflow.com/questions/6893968/how-to-get-the-return-value-from-a-thread-in-python) – python_user Feb 21 '21 at 01:30
  • @python_user thanks yea, I'm using something similar to this approach at the moment: https://stackoverflow.com/a/6894023/12283168. – samuelbrody1249 Feb 21 '21 at 02:00

0 Answers0