我在multiprocessing.Queue中放了一个包含multiprocessing.Queue的对象,我收到以下错误:
File "/usr/local/lib/python3.4/multiprocessing/queues.py", line 242, in _feed
obj = ForkingPickler.dumps(obj)
File "/usr/local/lib/python3.4/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
File "/usr/local/lib/python3.4/multiprocessing/queues.py", line 57, in __getstate__
context.assert_spawning(self)
File "/usr/local/lib/python3.4/multiprocessing/context.py", line 347, in assert_spawning
' through inheritance' % type(obj).__name__
RuntimeError: Queue objects should only be shared between processes through inheritance
我理解当multiprocessing.Queue尝试pickle multiprocessing.Queue时会导致错误。我已经尝试过使用multiprocessing.Manager来创建Sharing a queue among several processes中建议的队列的解决方案,它的工作原理是我可以将托管队列添加到另一个multiprocessing.Queue。但是,我遇到了this issue。
有没有办法解决我的对象中的酸洗问题,这样对象可以包含multiprocessing.Queue()而不是multiprocessing.Manager()。Queue()?