Revision 1887
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/parallel.py | ||
---|---|---|
85 | 85 |
self.queue = Queue_() |
86 | 86 |
self.active_tasks = 0 |
87 | 87 |
|
88 |
# Store a reference to the manager in self, because it will otherwise be |
|
89 |
# shutdown right away when it goes out of scope |
|
90 |
#self.manager = processing.Manager() |
|
91 |
#self.shared_rw = self.manager.Namespace() |
|
92 |
|
|
88 | 93 |
# Values that may be pickled by id() |
89 | 94 |
self.vars_id_dict = dicts.IdDict() |
90 | 95 |
self.share(self, *shared).share_vars(locals_).share_vars(globals()) |
91 | 96 |
|
92 | 97 |
def share(self, *values): |
93 |
'''Call this on all values that that should be pickled by id()''' |
|
98 |
'''Call this on all values that should be shared writably between all |
|
99 |
processes (and be pickled by id())''' |
|
94 | 100 |
self.vars_id_dict.add(*values) |
95 | 101 |
return self |
96 | 102 |
|
97 | 103 |
def share_vars(self, vars_): |
98 |
'''Call this on all vars that that should be pickled by id().
|
|
104 |
'''Call this on all vars that should be pickled by id(). |
|
99 | 105 |
Usage: self.share_vars(locals()) |
106 |
@param vars_ {var_name: value} |
|
100 | 107 |
''' |
101 | 108 |
self.vars_id_dict.add_vars(vars_) |
102 | 109 |
return self |
Also available in: Unified diff
parallel.py: MultiProducerPool: Added code to create a shared Namespace object, commented out. Updated share() doc comment to reflect that it will writably share the values as well.