Skip to content

Commit f1a82e4

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

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

git/repo/base.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy