Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Some files are never closed #60

Closed
Closed
@bochecha

Description

@bochecha

I'm working on a script using GitPython to loop over lots of Git repos, pull remote changes, etc...

At some point, I noticed that doingrepo.is_dirty() was opening some files which never got closed until the process exits, which in turns causes the tool to crash with "too many open files" after iterating over enough repos:

importosimportgit# Put here whatever Git repos you might have in the current folder# Listing more than one makes the problem more visiblerepos= ["ipset","libhtp"]raw_input("Check open files with `lsof -p %s | grep %s`"% (os.getpid(),os.getcwd()))fornameinrepos:repo=git.Repo(name)repo.is_dirty()delreporaw_input("Check open files again")# files are still open

I tried digging deeper down the GitPython stack, but couldn't find the actual cause.

In case that's helpful, below is the same as the previous snippet, but using directly the lowest-level gitdb objects I could find to open the files:

importosimportgitfromgitdb.utilimporthex_to_bin# Put here whatever Git repos you might have in the current folder# Listing more than one makes the problem more visiblerepos= ["ipset","libhtp"]raw_input("Check open files with `lsof -p %s | grep %s`"% (os.getpid(),os.getcwd()))raw_input("Check open files again")# files are still openfornameinrepos:repo=git.Repo(name)sha=hex_to_bin("71acab3ca115b9ec200e440188181f6878e26f08")fordbinrepo.odb._dbs:try:foritemindb._entities:# db._entities opens *.pack filesitem[2](sha)# opens *.idx filesexceptAttributeErrorase:# Not all DBs have this attributepassdelreporaw_input("Check open files again")# files are still open

But that's just where the files are open (well, in fact they are open even lower down but I didn't manage to go deeper), not where they are supposed to be closed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp