|
下面是一个有关多进程处理的代码问题:
TypeError: Pickling an Authenticati**tring object is disallowed for security reas**;
报错的位置逆序查找:
(1)
class Authenticati**tring(bytes):
def __reduce__(self):
from .context import get_spawning_popen
if get_spawning_popen() is None:
raise TypeError(
'Pickling an Authenticati**tring object is '
'disallowed for security reas**'
)
return Authenticati**tring, (bytes(self),)
(2)_tls = threading.local()
def get_spawning_popen():
return getattr(_tls, 'spawning_popen',None)
(3)
def getattr(object, name, default=None): # known special case of getattr
"""
getattr(object, name[, default]) -> value
Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.
"""
pass
(4)错误原因似乎是spawning_popen不是_tls的属性(该属性不存在与_thread._local中);因此getattr函数返回的是None,导致报错;
(5)求助大神帮助解决此问题,谢谢
|
|