Created
October 14, 2014 18:59
-
-
Save Seanny123/01d9e92fba631db07d85 to your computer and use it in GitHub Desktop.
Sharing dictionary of objects between processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
class Dog(): | |
def __init__(self, name = "joe"): | |
self.name = name | |
def bark(self): | |
print("woof") | |
mg = multiprocessing.Manager() | |
dt = dict() | |
lp = mg.list() | |
lp.append(dt) | |
print(lp) | |
dt["a"] = 1 | |
dt["b"] = 2 | |
lp[0] = dt | |
print(lp) | |
dt = dict() | |
lab = Dog("carl") | |
print(lab) | |
pup = Dog("steve") | |
print(pup) | |
dt[lab] = 1 | |
dt[pup] = 2 | |
lp[0] = dt | |
print(lp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment