X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d17049c214dda2a37a928b6ac1a4a348c8d3c9e2..540b72d62a94015f116ba077e279a5f10d666778:/sdk/python/arvados/api.py diff --git a/sdk/python/arvados/api.py b/sdk/python/arvados/api.py index a1493b904e..a7f3837599 100644 --- a/sdk/python/arvados/api.py +++ b/sdk/python/arvados/api.py @@ -261,11 +261,14 @@ def api_client( # can cause clients to appear to hang early. This can be removed after # we have a more general story for handling googleapiclient logs (#20521). client_logger = logging.getLogger('googleapiclient.http') - client_logger_unconfigured = ( - # "first time a client is instantiated" = thread that acquires this lock - # It is never released. - _googleapiclient_log_lock.acquire(blocking=False) - and not client_logger.hasHandlers() + # "first time a client is instantiated" = thread that acquires this lock + # It is never released. + # googleapiclient sets up its own NullHandler so we detect if logging is + # configured by looking for a real handler anywhere in the hierarchy. + client_logger_unconfigured = _googleapiclient_log_lock.acquire(blocking=False) and all( + isinstance(handler, logging.NullHandler) + for logger_name in ['', 'googleapiclient', 'googleapiclient.http'] + for handler in logging.getLogger(logger_name).handlers ) if client_logger_unconfigured: client_level = client_logger.level