I'm having some strange issues using subprocess.check_output(). At first I was just using subprocess.call() and everything was working fine. However when I simply switch out call() for check_output(), I receive a strange error.
Before code (works fine):
def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.call(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here successes.append(host) return successes After code (doesn't work):
def execute(hosts): ''' Using psexec, execute the batch script on the list of hosts ''' successes = [] wd = r'c:\\' file = r'c:\\script.exe' for host in hosts: res = subprocess.check_output(shlex.split(r'psexec \\\\%s -e -s -d -w %s %s' % (host,wd,file))) if res.... # Want to check the output here successes.append(host) return successes This gives the error: 
I couldnt redirect this because the program hangs here and I can't ctrl-c out. Any ideas why this is happening? What's the difference between subprocess.call() and check_output() that could be causing this?
Here is the additional code including the multiprocessing portion:
PROCESSES = 2 host_sublists_execute = [.... list of hosts ... ] poolE = multiprocessing.Pool(processes=PROCESSES) success_executions = poolE.map(execute,host_sublists_execute) success_executions = [entry for sub in success_executions for entry in sub] poolE.close() poolE.join() Thanks!