Skip to content

Commit bdb4c7c

Browse files
committed
fix(leaks, TCs): attempt to cleanup mman before deleting tmp-dirs
1 parent f1a82e4 commit bdb4c7c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Diff for: git/test/lib/helper.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77

88
import contextlib
99
from functools import wraps
10-
import sys
10+
import gc
1111
import io
1212
import logging
1313
import os
14+
import sys
1415
import tempfile
1516
import textwrap
1617
import time
1718

1819
from git.compat import string_types, is_win
1920
from git.util import rmtree, cwd
21+
import gitdb
2022

2123
import os.path as osp
24+
25+
2226
if sys.version_info[0:2] == (2, 6):
2327
import unittest2 as unittest
2428
else:
@@ -96,7 +100,6 @@ def wrapper(self):
96100
# a windows-only issue. In fact things should be deleted, as well as
97101
# memory maps closed, once objects go out of scope. For some reason
98102
# though this is not the case here unless we collect explicitly.
99-
import gc
100103
gc.collect()
101104
if not keep:
102105
rmtree(path)
@@ -144,9 +147,10 @@ def repo_creator(self):
144147
os.chdir(prev_cwd)
145148
rw_repo.git.clear_cache()
146149
rw_repo = None
147-
import gc
148-
gc.collect()
149150
if repo_dir is not None:
151+
gc.collect()
152+
gitdb.util.mman.collect()
153+
gc.collect()
150154
rmtree(repo_dir)
151155
# END rm test repo if possible
152156
# END cleanup
@@ -303,7 +307,8 @@ def remote_repo_creator(self):
303307
rw_daemon_repo.git.clear_cache()
304308
del rw_repo
305309
del rw_daemon_repo
306-
import gc
310+
gc.collect()
311+
gitdb.util.mman.collect()
307312
gc.collect()
308313
if rw_repo_dir:
309314
rmtree(rw_repo_dir)
@@ -357,7 +362,6 @@ def setUpClass(cls):
357362
each test type has its own repository
358363
"""
359364
from git import Repo
360-
import gc
361365
gc.collect()
362366
cls.rorepo = Repo(GIT_REPO)
363367

0 commit comments

Comments
 (0)