Extract method _init_application
This commit is contained in:
parent
ff287c2e5d
commit
ad7c93628b
@ -955,19 +955,21 @@ _application = None
|
|||||||
_application_lock = threading.Lock()
|
_application_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def application(environ, start_response):
|
def _init_application(config_path):
|
||||||
global _application
|
global _application
|
||||||
if _application is None:
|
|
||||||
with _application_lock:
|
with _application_lock:
|
||||||
if _application is None:
|
if _application is not None:
|
||||||
config_paths = []
|
return
|
||||||
if os.environ.get("RADICALE_CONFIG"):
|
configuration = config.load([config_path] if config_path else [],
|
||||||
config_paths.append(os.environ["RADICALE_CONFIG"])
|
|
||||||
configuration = config.load(config_paths,
|
|
||||||
ignore_missing_paths=False)
|
ignore_missing_paths=False)
|
||||||
filename = os.path.expanduser(configuration.get("logging",
|
filename = os.path.expanduser(configuration.get("logging", "config"))
|
||||||
"config"))
|
|
||||||
debug = configuration.getboolean("logging", "debug")
|
debug = configuration.getboolean("logging", "debug")
|
||||||
logger = log.start("radicale", filename, debug)
|
logger = log.start("radicale", filename, debug)
|
||||||
_application = Application(configuration, logger)
|
_application = Application(configuration, logger)
|
||||||
|
|
||||||
|
|
||||||
|
def application(environ, start_response):
|
||||||
|
config_path = os.environ.get("RADICALE_CONFIG")
|
||||||
|
if _application is None:
|
||||||
|
_init_application(config_path)
|
||||||
return _application(environ, start_response)
|
return _application(environ, start_response)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user