I have this little utility function that I use to execute external processes. In some cases, it hangs when I try to read the output of the process. Commenting out the output reading lines, it works.
def execute(command, cwd):
    command = command.split(' ')
    process = Popen(command,
        stderr=STDOUT, stdout=PIPE,
        cwd = cwd)
    # WITHOUT THIS IT WORKS
    #for line in process.stdout:    
    #    log.info('executing %s for user %s: %s' % (command, user.username, line))
    # ANOTHER TRY AT READING THE OUTPUT. ALSO MAKES IT HANG
    #output = p.communicate()[0]
    #log.info('executing %s for user %s: %s' % (command, user.username, output))
    process.wait()
Any help? I need to output for debugging purpose.
 
    