Merge "Add some comments explaining split_loggers flag logic"

This commit is contained in:
Zuul 2018-02-15 21:14:29 +00:00 committed by Gerrit Code Review
commit a516fdb176
1 changed files with 13 additions and 0 deletions

View File

@ -273,6 +273,8 @@ class Session(object):
if discovery_cache is None:
discovery_cache = {}
self._discovery_cache = discovery_cache
# NOTE(mordred) split_loggers kwarg default is None rather than False
# so we can distinguish between the value being set or not.
self._split_loggers = split_loggers
if timeout is not None:
@ -326,9 +328,20 @@ class Session(object):
return header
def _get_split_loggers(self, split_loggers):
"""Get a boolean value from the various argument sources.
We default split_loggers to None in the kwargs of the Session
constructor so we can track set vs. not set. We also accept
split_loggers as a parameter in a few other places. In each place
we want the parameter, if given by the user, to win.
"""
# None is the default value in each method's kwarg. None means "unset".
if split_loggers is None:
# If no value was given, try the value set on the instance.
split_loggers = self._split_loggers
if split_loggers is None:
# If neither a value was given on the method, nor a value was given
# on the Session constructor, then the value is False.
split_loggers = False
return split_loggers