Skip to content Skip to sidebar Skip to footer

Object.__new__(thread.lock) Is Not Safe, Use Thread.lock.__new__()

Hi I keep getting this error and I don't know how to circumvent this. I have the following code: class retrieve_account_data(Thread): _account_queue = None _dict_of_db_logg

Solution 1:

Don't use deepcopy (it is almost always certainly wrong). deepcopy will copy all referred to objects; in this case your object graph has some locks; they are not copiable by deepcopy and thus you get the error.


Solution 2:

Ok since I only needed very few data of the object I create a new one every time I get changed Account data. I deepcopy this keep the original in the thread and put the copy in the queue, which seemed to work so far.


Post a Comment for "Object.__new__(thread.lock) Is Not Safe, Use Thread.lock.__new__()"