Python multiprocessing manager class object thread/process safe -


i have following class shared between multiple consumers (using producer/consumer methodology). question involves methods called on class. need implement locks or manager class thread safe?

import multiprocessing mp multiprocessing.manager import basemanager  class sampleclass(object):      def __init__(self):         self._count = 0      # locking need implemented here?     def increment(self):         self._count += 1  basemanager.register('sampleclass', sampleclass) manager = basemanager() manager.start()  instance = manager.sampleclass()  jobs = [] in range(0, 5):     p = mp.process(target=some_func, args=(instance,))     jobs.append(p)     p.start()  p in jobs:     p.join() 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -