From 2372e64abd9bfed11153057dbdcd37b5bb2fdb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 2 Sep 2009 17:38:06 +0200 Subject: [PATCH] Fix call to exec_pg_command_pipe to wait the end of the command --- trytond/backend/postgresql/database.py | 16 ++++++++-------- trytond/tools/misc.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/trytond/backend/postgresql/database.py b/trytond/backend/postgresql/database.py index 07ad939dc7..4dfe2a4271 100644 --- a/trytond/backend/postgresql/database.py +++ b/trytond/backend/postgresql/database.py @@ -94,10 +94,10 @@ class Database(DatabaseInterface): cmd.append('--port=' + CONFIG['db_port']) cmd.append(database_name) - stdin, stdout = exec_pg_command_pipe(*tuple(cmd)) - stdin.close() - data = stdout.read() - res = stdout.close() + pipe = exec_pg_command_pipe(*tuple(cmd)) + pipe.stdin.close() + data = pipe.stdout.read() + res = pipe.wait() if res: raise Exception('Couldn\'t dump database!') return data @@ -129,11 +129,11 @@ class Database(DatabaseInterface): args2.append(' ' + tmpfile) args2 = tuple(args2) - stdin, stdout = exec_pg_command_pipe(*args2) + pipe = exec_pg_command_pipe(*args2) if not os.name == "nt": - stdin.write(data) - stdin.close() - res = stdout.close() + pipe.stdin.write(data) + pipe.stdin.close() + res = pipe.wait() if res: raise Exception('Couldn\'t restore database') diff --git a/trytond/tools/misc.py b/trytond/tools/misc.py index 245a5b1b9d..1381c70c7c 100644 --- a/trytond/tools/misc.py +++ b/trytond/tools/misc.py @@ -63,7 +63,7 @@ def exec_pg_command_pipe(name, *args): stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True, env=child_env) - return (pipe.stdin, pipe.stdout) + return pipe def exec_command_pipe(name, *args): prog = find_in_path(name)