Skip to content

Commit c679949

Browse files
author
yuniszhang
committed
解决get_auth并发问题
1 parent 3aad554 commit c679949

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

qcloud_cos/cos_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ def get_auth(self, Method, Bucket, Key, Expired=300, Headers={}, Params={}, Sign
241241
print (auth_string)
242242
"""
243243

244-
# python中默认参数只会初始化一次,而Headers={}是一个字典会传址(非传值),那么多个线程的Headers指向同一个内存地址,
245-
# request.headers=Headers,后续会用request.headers来保存Authorization值,在多线程并发时就会出现Authorization值被其它线程改写
246-
# 所以这里判断当Headers={}时重新生成实例,避免默认参数实例复用,导致多线程访问问题
244+
# python中默认参数只会初始化一次,这里重新生成可变对象实例避免多线程访问问题
247245
if not Headers:
248246
Headers = dict()
249247
if not Params:

0 commit comments

Comments
 (0)