在linux中使用python完成后进程不会被终止

2024-04-27 04:11:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python程序,一次只能运行10个进程。当第11个进程进入时,它等待其他进程完成。在MS-Windows环境中,进程在其任务完成并且其他进程能够运行时自动终止。但是在Linux环境中,进程即使在任务完成之后也不会终止?在

我必须以某种方式清除/终止进程吗?在

for processIndex in range(0, noOfProccesesToRun):
    dataToProcess = inputData[0:fileSize]
    inputData = inputData[fileSize:len(inputData)]
    curObject = ImportCclToMixPanel(dataToProcess)
    process = Process(target=curObject.importData)
    if currentProcess:
        childProcesses = currentProcess.get_children(recursive=True)
        while len(childProcesses) >= MAX_PROCESSES:
            childProcesses = currentProcess.get_children(recursive=True)
    process.start()

 def importData:
     //do stuff
     print "exiting

使用python版本2.7.5


Tags: truegetlen环境进程processrecursivechildren