Skip to content

Commit 1e515fa

Browse files
committed
Fix cleanup of connections.
1 parent 8d86551 commit 1e515fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

shared/wait-for-psql.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616

1717
args = arg_parser.parse_args()
1818

19+
conn = None
1920
start_time = time.time()
21+
error = ''
22+
2023
while (time.time() - start_time) < args.timeout:
2124
try:
2225
conn = psycopg2.connect(user=args.db_user, host=args.db_host, port=args.db_port, password=args.db_password, dbname=args.db_name)
23-
error = ''
26+
conn.close()
2427
break
2528
except psycopg2.OperationalError as e:
2629
error = e
27-
else:
28-
conn.close()
30+
2931
time.sleep(1)
3032

3133
if error:

0 commit comments

Comments
 (0)