Speed up non-daemon rootwrap command line invocation

Move the import to the spot where we really need it. This
speeds up the command line invocation (non-daemon) a bit.

Closes-Bug: #1440744
Change-Id: I401c290e0b61912b5dce106d3fdda91795a8cb12
This commit is contained in:
Davanum Srinivas 2015-04-06 09:58:57 -04:00
parent 37b8d376fc
commit 1782ef1444

View File

@ -37,7 +37,6 @@ import sys
from six import moves from six import moves
from oslo_rootwrap import daemon as daemon_mod
from oslo_rootwrap import wrapper from oslo_rootwrap import wrapper
RC_UNAUTHORIZED = 99 RC_UNAUTHORIZED = 99
@ -92,6 +91,10 @@ def main(run_daemon=False):
filters = wrapper.load_filters(config.filters_path) filters = wrapper.load_filters(config.filters_path)
if run_daemon: if run_daemon:
# NOTE(dims): When not running as daemon, this import
# slows us down just a bit. So moving it here so we have
# it only when we need it.
from oslo_rootwrap import daemon as daemon_mod
daemon_mod.daemon_start(config, filters) daemon_mod.daemon_start(config, filters)
else: else:
run_one_command(execname, config, filters, sys.argv) run_one_command(execname, config, filters, sys.argv)