慕丝7291255
这是Job对象方法的示例代码,但不是subprocess使用win32api.CreateProcessimport win32processimport win32jobstartup = win32process.STARTUPINFO()(hProcess, hThread, processId, threadId) = win32process.CreateProcess(None, command, None, None, True, win32process.CREATE_BREAKAWAY_FROM_JOB, None, None, startup)hJob = win32job.CreateJobObject(None, '')extended_info = win32job.QueryInformationJobObject(hJob, win32job.JobObjectExtendedLimitInformation)extended_info['BasicLimitInformation']['LimitFlags'] = win32job.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSEwin32job.SetInformationJobObject(hJob, win32job.JobObjectExtendedLimitInformation, extended_info)win32job.AssignProcessToJobObject(hJob, hProcess)