def handle(self, *args, **options):
try:
connection = connections[options['database']]
except ConnectionDoesNotExist:
raise CommandError('Database "%s" does not exist in settings' % options['database'])
for i in range(0, options['retries']):
try:
connection.cursor()
except OperationalError:
i += 1
self.stdout.write('{} / {}: Waiting for database...'.format(i, options['retries']))
sleep(options['sleep_time'])
else:
self.stdout.write(self.style.SUCCESS('Successfully connected to database'))
return
raise CommandError('Number of retries reached, exiting')
wait_for_database.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录