Dear All
I am running this piece of code:
from threading import Thread
import copy
class Ashish(Thread):
def __init__(self, i):
Thread.__init__(self)
self.foo = i
def run(self):
print (self, self.foo)
d= Ashish(4)
e = copy.deepcopy(d) <--- Exception here....
d.start()
e.start()
d.join()
e.join()
But I am getting this error:
>>>
Traceback (most recent call last):
File "D:\Profiles\ntb837\Desktop\threadprob.py", line 13, in <module>
e = copy.deepcopy(d)
File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python31\lib\copy.py", line 295, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python31\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python31\lib\copy.py", line 295, in _reconstruct
state = deepcopy(state, memo)
File "C:\Python31\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "C:\Python31\lib\copy.py", line 235, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "C:\Python31\lib\copy.py", line 173, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Python31\lib\copy.py", line 280, in _reconstruct
y = callable(*args)
File "C:\Python31\lib\copyreg.py", line 88, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(_thread.lock) is not safe, use
_thread.lock.__new__()
Could someone please help me find a solution?
Regards,
Ashish Vyas
--
http://mail.python.org/mailman/listinfo/python-list