Skip to content

Commit

Permalink
Merge pull request #4394 from Lucas-C/master
Browse files Browse the repository at this point in the history
Avoid pip.main leaking loggers - fixes #3043
  • Loading branch information
dstufft authored Apr 2, 2017
2 parents 5748d87 + 3b3dfac commit 07e7912
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pip/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def main(self, args):
)
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
Expand Down Expand Up @@ -249,6 +251,10 @@ def main(self, args):
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

Expand Down

0 comments on commit 07e7912

Please sign in to comment.