Skip to content

Commit 31b2ccd

Browse files
authored
dulwich: close dulwich repo after clone (#203)
Otherwise, we may end up leaking lots of open file handles that dulwich keeps open for performance reasons. See jelmer/dulwich#1155.
1 parent 4a8a1fa commit 31b2ccd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/scmrepo/git/backend/dulwich/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import stat
6+
from contextlib import closing
67
from functools import partial
78
from io import BytesIO, StringIO
89
from typing import (
@@ -198,7 +199,9 @@ def clone(
198199
repo = clone_from(depth=depth, branch=os.fsencode(shallow_branch))
199200
else:
200201
repo = clone_from()
201-
cls._set_default_tracking_branch(repo)
202+
203+
with closing(repo):
204+
cls._set_default_tracking_branch(repo)
202205
except Exception as exc:
203206
raise CloneError(url, to_path) from exc
204207

0 commit comments

Comments
 (0)