I am writing application which is running multiple processes. Each process operates on the same dictionary (locked by Lock()). How to make sure we can edit that dictionary inside process ?
Example:
from multiprocessing import Process
p = Process(target=self.search_simple_process, args=(self,content,patterns,))
p.start()
p.join()
self.out(patterns)
def search_simple_process(self, content, patterns):
for pattern in patterns.keys():
try:
if pattern in content:
patterns[pattern] += 1 #to add Lock() for this
except:
self.out("Exception")
Right now the results displayed are always original patterns dictionary (not modified).
Thanks, Michal