introduce a timeout for MongoDB connection
This commit is contained in:
parent
2bd8ac96ee
commit
d1e2fdbb31
1 changed files with 12 additions and 2 deletions
12
ibt2.py
12
ibt2.py
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""I'll Be There, 2 (ibt2) - an oversimplified attendees registration system.
|
"""I'll Be There, 2 (ibt2) - an oversimplified attendees registration system.
|
||||||
|
|
||||||
Copyright 2016-2017 Davide Alberani <da@erlug.linux.it>
|
Copyright 2016-2018 Davide Alberani <da@erlug.linux.it>
|
||||||
RaspiBO <info@raspibo.org>
|
RaspiBO <info@raspibo.org>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
@ -663,7 +664,16 @@ def run():
|
||||||
ssl_options = dict(certfile=options.ssl_cert, keyfile=options.ssl_key)
|
ssl_options = dict(certfile=options.ssl_cert, keyfile=options.ssl_key)
|
||||||
|
|
||||||
# database backend connector
|
# database backend connector
|
||||||
|
_count = 0
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
db_connector = monco.Monco(url=options.mongo_url, dbName=options.db_name)
|
db_connector = monco.Monco(url=options.mongo_url, dbName=options.db_name)
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
time.sleep(1)
|
||||||
|
_count += 1
|
||||||
|
if _count > 20:
|
||||||
|
raise
|
||||||
|
|
||||||
# global settings stored in the db
|
# global settings stored in the db
|
||||||
global_settings = {}
|
global_settings = {}
|
||||||
|
|
Loading…
Reference in a new issue