0

I am trying to save an output of multiple threading to the variable Output_1 and Output_2. My code is as follows.

import multiprocessing
from threading import Thread
from multiprocessing import Pool
import threading
import time

golbal_data = []


def job(R003_file_List):
    ...............skip..............
    return Capex_date_DF


thread1  = threading.Thread(target = job(R003_file_List[0:4]))
thread1.start()
thread1.join()
Output_1 = thread1.result()


thread12 = threading.Thread(target = job(R003_file_List[5:8]))
thread2.start()
thread2.join()
Output_2 = thread12.result()


However, it shows the error 'Thread' object has no attribute 'result'. Please help me to find the bug.

CanaryTheBird
  • 239
  • 1
  • 11
  • 1
    The error is clear enough ! Thread class doesn’t have this method. See this link for possible solution sohttps://stackoverflow.com/questions/6893968/how-to-get-the-return-value-from-a-thread – HazemGomaa Apr 24 '23 at 04:25
  • If you need to call `t.join()` _immediately_ after calling `t.start()`, that means that there was no point in ever creating the thread `t` in the first place. You can improve your program by simply calling the `target` function instead of creating the new thread. https://stackoverflow.com/a/76092224/801894 – Solomon Slow Apr 24 '23 at 13:53

0 Answers0