15 lines
313 B
Python
15 lines
313 B
Python
import socket
|
|
import time
|
|
import os
|
|
|
|
port = int(os.environ["SQL_PORT"]) # 5432
|
|
db_name = os.environ["SQL_DATABASE"]
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
while True:
|
|
try:
|
|
s.connect((db_name, port))
|
|
s.close()
|
|
break
|
|
except socket.error as ex:
|
|
time.sleep(0.1) |