Skip to content

Random git.repo.base.Repo.__del__ exceptions #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xsteve opened this issue Mar 15, 2017 · 2 comments
Closed

Random git.repo.base.Repo.__del__ exceptions #610

xsteve opened this issue Mar 15, 2017 · 2 comments

Comments

@xsteve
Copy link

xsteve commented Mar 15, 2017

When an exception is thrown the cleanup of Repo objects causes some very strange back traces.
When I run my test script several times. I have different results. Sometimes it works.
On other runs I have either the errors a), b) or c)

/work/GitPython/git/repo/base.py

def __del__(self):
    self.close()                  # line 189

def close(self):
    if self.git:
        self.git.clear_cache()
        gc.collect()              # line 194
        gitdb.util.mman.collect() # line 195
        gc.collect()

a)

Exception ignored in: <bound method GitRepository.__del__ of <GitRepository '/big/yocto/msc-ldk'>>
Traceback (most recent call last):
  File "/work/GitPython/git/repo/base.py", line 189, in __del__
  File "/work/GitPython/git/repo/base.py", line 195, in close
AttributeError: 'NoneType' object has no attribute 'mman'

b)

Exception ignored in: <bound method GitRepository.__del__ of <GitRepository '/big/yocto/msc-ldk'>>
Traceback (most recent call last):
  File "/work/GitPython/git/repo/base.py", line 189, in __del__
  File "/work/GitPython/git/repo/base.py", line 194, in close
TypeError: 'NoneType' object is not callable

c)

Exception ignored in: <bound method GitRepository.__del__ of <GitRepository '/big/yocto/msc-ldk'>>
Traceback (most recent call last):
  File "/work/GitPython/git/repo/base.py", line 189, in __del__
  File "/work/GitPython/git/repo/base.py", line 194, in close
AttributeError: 'NoneType' object has no attribute 'collect'

One solution to get rid of the back traces is to wrap the self.close() call in a try-except handler:

def __del__(self):
    try:
        self.close()
    except:
        pass
@Byron
Copy link
Member

Byron commented Apr 9, 2017

Thanks for providing all the details, and even the fix.
I took the liberty to implement it, and hope this will improve the situation (or even fix it :)).

@xsteve
Copy link
Author

xsteve commented Apr 10, 2017

Thanks :-)

Your commit fixes this problem for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants