Does sending a dictionary through multiprocessing.queue really mutate it somehow?

I have a setting in which I send the dictionary through multiprocessing.queue and do some things with it. I was getting the unusual “dictionary size changed by repeating the error” when I did not change anything in the dictionary. Here's the trace, although this is not very useful:

 Traceback (most recent call last): File "/usr/lib/python2.6/multiprocessing/queues.py", line 242, in _feed send(obj) RuntimeError: dictionary changed size during iteration 

So I tried to change the dictionary to an immutable dictionary to see where it changes. Here I got the trace:

 Traceback (most recent call last): File "/home/jason/src/interface_dev/jiva_interface/jiva_interface/delta.py", line 54, in main msg = self.recv() File "/home/jason/src/interface_dev/jiva_interface/jiva_interface/process/__init__.py", line 65, in recv return self.inqueue.get(timeout=timeout) File "/usr/lib/python2.6/multiprocessing/queues.py", line 91, in get res = self._recv() File "build/bdist.linux-i686/egg/pysistence/persistent_dict.py", line 22, in not_implemented_method raise NotImplementedError, 'Cannot set values in a PDict' NotImplementedError: Cannot set values in a PDict 

This is a little strange because, as far as I can tell, I do nothing but get it out of the lineup. Can someone shed light on what is happening here?

+4
source share
1 answer

Recently, a bug was fixed where garbage collection could change the size of a dictionary that contained weak links and which could cause the "resized word size during iteration" error. I don’t know if this is your problem, but the multiprocessing package uses weak links.

See http://bugs.python.org/issue7105

+2
source

Source: https://habr.com/ru/post/1307154/


All Articles