Just experimenting and learning, and I know how to create a shared dictionary that can be accessed with multiple proceses but I\'m not sure how to keep the dict synced. de
Well, the Manager
class seems to supply only a fixed number of predefined data structures which can be shared among processes, and defaultdict
is not among them. If you really just need that one defaultdict
, the easiest solution would be to implement the defaulting behavior on your own:
def test(k, multi_dict):
if k not in multi_dict:
multi_dict[k] = 0
multi_dict[k] += 1