subprocess.check\u ouput在eclipse中挂起,并且没有为python语言中的pg\u转储进行备份

subprocess.check\u ouput在eclipse中挂起,并且没有为python语言中的pg\u转储进行备份,python,python-2.7,postgresql-9.1,Python,Python 2.7,Postgresql 9.1,postgres转储无法正常工作,我通过eclipse和linux(ubuntu)后台操作系统运行了下面的python程序 问题是eclipse挂起,跟踪信息以及备份文件为空 import os import subprocess if __name__ == '__main__': print "test hello" localhost = 'localhost' port = '5432' role = 'serverdb_user' dump_

postgres转储无法正常工作,我通过eclipse和linux(ubuntu)后台操作系统运行了下面的python程序

问题是eclipse挂起,跟踪信息以及备份文件为空

import os
import subprocess

if __name__ == '__main__':
    print "test hello"

    localhost = 'localhost'
    port = '5432'
    role = 'serverdb_user'
    dump_dir = '/home/backupfile/'
    db_username = 'empserverdb_user'
    db_names = 'emp1'

    try:
        bkp_file = 'backup1'
        file_path = os.path.join(dump_dir, bkp_file)
        print file_path
        dumper_cmd = ['pg_dump', '-h', localhost, '-p', port, '-U', db_username, '--role', role, '-W', '-Fc', '-v', '-f', file_path, db_names]
        print dumper_cmd
        subprocess.check_output(dumper_cmd)
    except subprocess.CalledProcessError, ex:
        print("Couldn't back up database {0}: pg_dump returned {1} with output {2}".format(db_names, ex.returncode, ex.output))
    except Exception, ex:
        print("Couldn't backup database {0}: unexpected error {1}".format(db_names, ex))

通过将密码分配给env,可以解决此问题。以及人们在岗位上的建议