我有一个使用队列对象列表的类。我需要将这个类进行pickle处理,包括保存在队列对象中的信息。例如:
import Queue
import pickle
class QueueTest(object):
def __init__(self):
self.queueList = []
def addQueue(self):
q = Queue.Queue()
q.put('test')
self.queueList.append(q)
obj = QueueTest()
obj.addQueue()
with open('pickelTest.dat','w') as outf:
pickle.dump(obj,outf)
返回错误
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle lock objects
有没有绕过pickle队列对象的方法?
Queue.Queue
的同步特性吗?也就是说,你是在使用队列来在不同的线程之间进行通信,还是只是作为一个普通的数据结构? - Blckknght