1

I am sharing a dictionary between processes and each process inserts a entry into the dict, where the value for the keys in the dictionary can be a list or a gdb.Value instance. Each processes is doing something like this

mydict["key"] = [[2], gdb.Value(someaddress), 3, 4]

When the above line is executed I get the below error, looks like its because i am inserting gdb.Value, this works if in case of a object() instance

Traceback (most recent call last):
  File "/test.py", line 631, in insert
    mydict["key"] = [[2], 1, 3, 4]
  File "<string>", line 2, in __setitem__
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 774, in _callmethod
    raise convert_to_error(kind, result)
RemoteError: 
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 240, in serve_client
    request = recv()
TypeError: Value object creation takes only 1 argument

I see another issue too, looping over the dict gives me below error

Traceback (most recent call last):
  File "/test.py", line 1214, in <module>
    for item in mydict:
  File "<string>", line 2, in __getitem__
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 774, in _callmethod
    raise convert_to_error(kind, result)
PMat
  • 2,039
  • 2
  • 29
  • 46

1 Answers1

0

Please post a self-contained example that fails. Here's my best attempt to guess at one from what you wrote, but it works fine:

import multiprocessing as mp

def e(tag, d):
    d[tag] = [[tag], tag, tag, tag]

if __name__ == '__main__':
    d = mp.Manager().dict()
    ps = []
    for i in range(4):
        ps.append(mp.Process(target=e, args=(str(i), d)))
        ps[-1].start()
    for p in ps:
        p.join()
    print(d)

And it prints:

{'0': [['0'], '0', '0', '0'],
 '1': [['1'], '1', '1', '1'],
 '2': [['2'], '2', '2', '2'],
 '3': [['3'], '3', '3', '3']}
Tim Peters
  • 67,464
  • 13
  • 126
  • 132
  • Thank you for the quick reply. I realised that this is specific to my use case. I am inserting object instance into the list, even in case of object(), it works. But i am inserting a gdb.Value(). There is also error when looping over the dict. Please see the updated question – PMat Jun 21 '17 at 16:51
  • In you example, if i loop over d, it throws me the error. Please see the updated question – PMat Jun 21 '17 at 16:58