def _ensureConnection(self):
# If connection is already made close it.
from django.db import connection
if connection.connection is not None:
connection.close()
# Loop forever until a connection can be made.
while True:
try:
connection.ensure_connection()
except Exception:
log.err(_why=(
"Error starting: "
"Connection to database cannot be established."))
time.sleep(1)
else:
# Connection made, now close it.
connection.close()
break
评论列表
文章目录