Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f1a82e4

Browse filesBrowse files
committed
fix(leaks): repo context-man to cleanup global mman on repo-delete
Improve API for problems like #553.
1 parent 2f207e0 commit f1a82e4
Copy full SHA for f1a82e4

File tree

1 file changed

+14
-0
lines changed
Filter options

1 file changed

+14
-0
lines changed

‎git/repo/base.py

Copy file name to clipboardExpand all lines: git/repo/base.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import os.path as osp
3434

3535
from .fun import rev_parse, is_git_dir, find_submodule_git_dir, touch
36+
import gc
37+
import gitdb
3638

3739

3840
log = logging.getLogger(__name__)
@@ -177,9 +179,21 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
177179
args.append(self.git)
178180
self.odb = odbt(*args)
179181

182+
def __enter__(self):
183+
return self
184+
185+
def __exit__(self, exc_type, exc_value, traceback):
186+
self.close()
187+
180188
def __del__(self):
189+
self.close()
190+
191+
def close(self):
181192
if self.git:
182193
self.git.clear_cache()
194+
gc.collect()
195+
gitdb.util.mman.collect()
196+
gc.collect()
183197

184198
def __eq__(self, rhs):
185199
if isinstance(rhs, Repo):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.