I have implemented below code for multiprocessing that can handle multiple request concurrently but I'm getting below error. For that i use producer and consumer concept where producing putting process in queue and consumer consume that process and do some JOB.
Traceback (most recent call last):
p.start()
File "/usr/lib/python2.7/multiprocessing/process.py", line 130, in start
self._popen = Popen(self)
File "/usr/lib/python2.7/multiprocessing/forking.py", line 121, in __init__
self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory
queue = Queue()
lock = Lock()
producers = []
consumers = []
for frame in frames:
`enter code here`producers.extend([Process(target=self.producer, args=(queue, lock, frame)) for i in xrange(cpu_count())])
for i in range(50):
p = Process(target=self.consumer, args=(queue, lock))
p.daemon = True
consumers.append(p)
for p in producers:
#time.sleep(random.randint(0, 5))
p.start()
for c in consumers:
#time.sleep(random.randint(0, 5))
c.start()
# Like threading, we have a join() method that synchronizes our program
for p in producers:
p.join()
u_end = time.time()
print u_start, u_end
print('Parent process exiting...')