1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Avoid pip.main leaking loggers - fixes #3043

This commit is contained in:
Lucas Cimon 2017-03-31 15:15:10 +02:00
parent 5748d87ab3
commit 3b3dfac2c1

View file

@ -210,6 +210,8 @@ class Command(object):
)
sys.exit(VIRTUALENV_NOT_FOUND)
original_root_handlers = set(logging.root.handlers)
try:
status = self.run(options, args)
# FIXME: all commands should return an exit status
@ -249,6 +251,10 @@ class Command(object):
retries=0,
timeout=min(5, options.timeout)) as session:
pip_version_check(session, options)
# Avoid leaking loggers
for handler in set(logging.root.handlers) - original_root_handlers:
# this method benefit from the Logger class internal lock
logging.root.removeHandler(handler)
return SUCCESS