-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
When using multiprocessing's Queue class to share PCBO instances between processes, the attribute _degree is missing after extraction. A minimal example:
import multiprocessing as mp
from qubovert import PCBO
def produce(queue):
pcbo = PCBO({(0,1): -5})
queue.put(pcbo)
def consume(queue):
pcbo = queue.get() # AttributeError occurs here
print(pcbo)
if __name__ == '__main__':
queue = mp.Queue()
process1 = mp.Process(target=produce, args=(queue,))
process2 = mp.Process(target=consume, args=(queue,))
process1.start()
process2.start()
process1.join()
process2.join()Executing this produces the following error:
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!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels