here is a piece of code:
while (int(currentMemoryUsage[2]) < 50 and int(current_cpu_usage)<80):
self.event_list.append(Event())
p = Process(target=self.classA.functionB,
args=(a, b, self.lock, self.event_list[counter]))
print('create process')
self.process_list.append(p)
self.event_list[counter].clear()
counter += 1
print("about to start process")
p.start()
print("new process started")
After start a number of processes, it will stuck at p.start(), it will successfully create new process, but stuck at p.start(), does anyone know why this happen?
EDIT 1:
at first I thought it stuck at p.start()
because the new process started are not printed out and I see there are some zombie processes in the system.
But after I add signal.alarm(180)
before p.start()
to force it jump over the blocked line, I am still not seeing the lines after that get executed. The edited code is shown below.
while True:
if (int(current_memory_usage[2]) < 50 and int(current_cpu_usage)<80):
try:
self.event_list.append(Event())
p = Process(target=self.classA.functionB,
args=(a, b, self.lock, self.event_list[counter]))
print('create process')
self.process_list.append(p)
self.event_list[counter].clear()
counter += 1
print("about to start process")
signal.alarm(180)
p.start()
print("new process started")
signal.alarm(0)
except Exception as e:
print("catch an exception" + str(e))
print(" I am just a line in the while")
In other words, I not seeing "new process started" (but the child process did start), nor "catch an exception", nor " I am just a line in the while". I guess it might be the main process exit somehow, but I am not getting any error why the main process quits. Anyone has idea?