You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using multiprocessing's Queue class to share PCBO instances between processes, the attribute _degree is missing after extraction. A minimal example:
Process Process-2:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "test.py", line 9, in consume
pcbo = queue.get()
File "/usr/lib/python3.8/multiprocessing/queues.py", line 116, in get
return _ForkingPickler.loads(res)
File "/home/muecke/.local/lib/python3.8/site-packages/qubovert/utils/_bo_parentclass.py", line 219, in __setitem__
super().__setitem__(key, value)
File "/home/muecke/.local/lib/python3.8/site-packages/qubovert/utils/_pubomatrix.py", line 384, in __setitem__
self._degree = max(self._degree, len(k))
AttributeError: 'PCBO' object has no attribute '_degree'
OS: Linux (Manjaro, kernel 5.7.9-1-MANJARO)
Python version 3.8.3, qubovert version 1.2.3
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Hi, thanks for raising the issue! I'm afraid I'm not very familiar with the multiprocessing package or Queue object. Have you been able to reproduce this error in another way?
This seems to be an issue with serialization, as I was able to reproduce it with pickle:
importpicklefromqubovertimportPCBOpcbo=PCBO({(0, 1): -5}) # error happens only when instance is not emptydata=pickle.dumps(pcbo)
pcbo_=pickle.loads(data) # AttributeError occurs here
The clean solution will probably be to implement the __getstate__() and __setstate__() methods for all instances of PCBO, QUBO etc., which store and restore the object states manually. I think attributes like _degree starting with an underscore are problematic for serialization, because Python renames such attributes in subclasses.
Another solution might be to just rename attributes starting with _ to something without underscore.
When using multiprocessing's Queue class to share PCBO instances between processes, the attribute
_degree
is missing after extraction. A minimal example:Executing this produces the following error:
OS: Linux (Manjaro, kernel
5.7.9-1-MANJARO
)Python version 3.8.3,
qubovert
version 1.2.3Thanks in advance!
The text was updated successfully, but these errors were encountered: