[英]Get return from a thread - return type is dataframe
there is thread in my program which calls a function which returns multiple values it also contains a dataframe how can i get these values? 我的程序中有一个线程调用一个返回多个值的函数,它还包含一个数据帧,我如何获得这些值? the thread is called from a for loop 从for循环调用该线程
ml1234=threading.Thread(target=load_syscom_ascii(fleName=fl, columns=self.cols, finalcsv=self.finalcsv,
out=self.outdir))
ml1234.start()
head, dfg, df1 =ml1234.join()
First of all, you shouldn't call the target function when creating a Thread object, pass the function and args separately, like: 首先,在创建Thread对象时不应调用目标函数,而应分别传递函数和args,例如:
ml1234 = threading.Thread(target=load_syscom_ascii, kwargs={'fileName': fl, 'columns': self.cols, 'finalcsv': self.finalcsv, 'out': self.outdir})
Otherwise the function will be called in the main thread immediately. 否则,该函数将立即在主线程中调用。
The ways to get return values from the thread are listed in this answer - how to get the return value from a thread in python? 此答案中列出了从线程获取返回值的方法- 如何从python中的线程获取返回值? , as was already suggested. ,正如已经建议的那样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.