我有类似的问题,如下所述: Threading not working
我尝试通过传递arg =(None,)来解决问题,但这给了我一个追溯:
这允许我执行下载,但是主窗口冻结:
def _Downloader(self):
self.processaa = threading.Thread(target = (dbimp.FDown._FUpdate(self)))
self.processaa.start()
如链接中所述,我应该分别传递参数:
def _Downloader(self):
self.processaa = threading.Thread(target = (dbimp.FDown._FUpdate), args=(None,))
self.processaa.start()
但是我收到以下引用:
H:\pyt\tool>crap.py
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\...\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\...\Python37-32\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "H:\pyt\tool\dbimp.py", line 327, in _FUpdate
self.file_names_update = ("MASTER", "RESERVED", "DEREG", "ACFTREF")
AttributeError: 'NoneType' object has no attribute 'file_names_update'
该函数无需线程即可正常工作。
答案 0 :(得分:0)
每个furas的评论应如下所示:
def _Downloader(self):
self.processaa = threading.Thread(target = (dbimp.FDown._FUpdate), args=(self,))
self.processaa.start()
和线程工作正常。