diff options
author | James E. Blair <jeblair@redhat.com> | 2017-10-09 13:37:42 -0700 |
---|---|---|
committer | James E. Blair <jeblair@redhat.com> | 2017-10-09 13:37:42 -0700 |
commit | 454fedab8ea138057cc73aa545ecb2cf0dac5b4b (patch) | |
tree | 917efe7abe34cb5f710b76cbc5d1ade8dbd7ca74 /git/repo/base.py | |
parent | f237620189a55d491b64cac4b5dc01b832cb3cbe (diff) | |
download | gitpython-454fedab8ea138057cc73aa545ecb2cf0dac5b4b.tar.gz |
Only gc.collect() under windows
Under Windows, tempfile objects are holding references to open files
until the garbage collector closes them and frees them. Explicit
calls to gc.collect() were added to the finalizer for the Repo class
to force them to be closed synchronously. However, this is expensive,
especially in large, long-running programs. As a temporary measure
to alleviate the performance regression on other platforms, only
perform these calls when running under Windows.
Fixes #553
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index 9ed3f714..d373f582 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -209,9 +209,17 @@ class Repo(object): def close(self): if self.git: self.git.clear_cache() - gc.collect() + # Tempfiles objects on Windows are holding references to + # open files until they are collected by the garbage + # collector, thus preventing deletion. + # TODO: Find these references and ensure they are closed + # and deleted synchronously rather than forcing a gc + # collection. + if is_win: + gc.collect() gitdb.util.mman.collect() - gc.collect() + if is_win: + gc.collect() def __eq__(self, rhs): if isinstance(rhs, Repo): |