Skip to content

Commit 9b705e5

Browse files
authored
Merge pull request gitpython-developers#686 from jeblair/issue-605
Only gc.collect() under windows
2 parents 3288a2d + a98c653 commit 9b705e5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

git/repo/base.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,17 @@ def __del__(self):
209209
def close(self):
210210
if self.git:
211211
self.git.clear_cache()
212-
gc.collect()
212+
# Tempfiles objects on Windows are holding references to
213+
# open files until they are collected by the garbage
214+
# collector, thus preventing deletion.
215+
# TODO: Find these references and ensure they are closed
216+
# and deleted synchronously rather than forcing a gc
217+
# collection.
218+
if is_win:
219+
gc.collect()
213220
gitdb.util.mman.collect()
214-
gc.collect()
221+
if is_win:
222+
gc.collect()
215223

216224
def __eq__(self, rhs):
217225
if isinstance(rhs, Repo):

0 commit comments

Comments
 (0)