python-3.x - 解决线程中的组参数错误
问题描述
我正在使用线程来下载、转换视频并删除它。但是,当我使用线程时,它给了我一个错误AssertionError: group argument must be None for now
线程工作正常,直到之前运行 3 次,但它突然显示此错误。
我认为 group 参数是默认的 None 但我只是在参数中添加了 'group = None' 。现在它显示一个错误说TypeError: __init__() got multiple values for argument 'group'
def video_download(parent_file, url):
#checking if it succeed or not for logging
fail = []
success = []
#which number in the list the program is in
check = 1
#check if the url is playlist or single video
if url.find("list") != -1:
pl = Playlist(url)
links = pl.parse_links()
#length of list
total = len(links)
print("\n start download")
for l in links:
t1 = threading.Thread(l,target= download_multi, group = None, args=(l,check,parent_file,success,fail,total))
t1.start()
time.sleep(1)
t2 = threading.Thread(target= download_multi, group = None, args=(l,check,parent_file,success,fail,total))
t2.start()
time.sleep(1)
t3 = threading.Thread(target= download_multi, group = None, args=(l,check,parent_file,success,fail,total))
t3.start()
time.sleep(1)
t1.join()
t2.join()
t3.join()
没有组的错误代码 = 无
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\pydevd.py", line 2060, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\pydevd.py", line 2054, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\pydevd.py", line 1405, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\pydevd.py", line 1412, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 179, in <module>
recieve_input()
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 37, in recieve_input
video_download(parent_file, url)
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 102, in video_download
t1 = threading.Thread(l,target= download_multi, args=(l,check,parent_file,success,fail,total))
File "C:\Users\paulm\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 786, in __init__
assert group is None, "group argument must be None for now"
AssertionError: group argument must be None for now
组的错误代码 = 无
Traceback (most recent call last):
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 179, in <module>
recieve_input()
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 37, in recieve_input
video_download(parent_file, url)
File "C:/Users/paulm/Desktop/Github/git/YoutubeDownloader/main.py", line 102, in video_download
t1 = threading.Thread(l,target= download_multi, group = None, args=(l,check,parent_file,success,fail,total))
TypeError: __init__() got multiple values for argument 'group'
问题解决了。第一个线程有错字,修复后它工作得很好。
解决方案
该t1 = threading.Thread(l,target=
线与t2和t3不一致
额外的l
被错误地视为组 arg 的默认值
错字?
推荐阅读
- webpack - 缺少变量的 SCSS 的 Mixin Webpack 错误
- rust - 获取 rust 的商和余数 (DIVMOD) 的函数是什么?
- node.js - 如何使用 expressjs 和 nodejs 将文件上传到 IPFS
- android - 制作自适应颤振应用程序的最佳方法是什么?
- c# - 默认设置为 AsNoTracking 的 DBContext
- python - 使用 Python 的所有 4 位数字组合 (0-9)
- javascript - React、Context 和 Session Storage:导航栏在登录时正确更新,但在注销时不正确
- ruby-on-rails - devise-jwt 在身份验证之前生成令牌?
- javascript - 如何将 JSON 转换为 GeoJson JavaScript
- python - 如何将浏览器网络日志附加到硒测试报告?