Skip to content

cmd.py: AutoInterrupt.__del__: Avoid some unwanted tracebacks by catching some more errors #576

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

Conversation

xsteve
Copy link

@xsteve xsteve commented Feb 1, 2017

I see the following in an application that uses GitPython:
When the application raises an unknown exception it terminates with sys.exit(2)

When the exception is raised by GitPython I see that I land in the following line (although my application is running on Linux):
call(("TASKKILL /F /T /PID %s 2>nul 1>nul" % str(proc.pid)), shell=True)

Here I get the following exception (not always but in some cases):
Exception ignored in: <bound method GitRepository.del of <GitRepository '/big/yocto/msc-ldk'>>
Traceback (most recent call last):
File "/home/srei/work/git/GitPython/git/repo/base.py", line 182, in del
File "/home/srei/work/git/GitPython/git/cmd.py", line 965, in clear_cache
File "/home/srei/work/git/GitPython/git/cmd.py", line 265, in del
File "/usr/lib/python3.4/subprocess.py", line 537, in call
TypeError: 'NoneType' object is not callable

I took a look at the attribute error exception: it was the following:
'NoneType' object has no attribute 'SIGTERM'

I fixed this problem by wrapping the call line in a try: except block

However there remained another problem (that happened also only in rare cases):
Exception ignored in: <bound method GitRepository.del of <GitRepository '/big/yocto/msc-ldk'>>
Traceback (most recent call last):
File "/home/srei/work/git/GitPython/git/repo/base.py", line 182, in del
File "/home/srei/work/git/GitPython/git/cmd.py", line 967, in clear_cache
File "/home/srei/work/git/GitPython/git/cmd.py", line 254, in del
File "/usr/lib/python3.4/subprocess.py", line 1686, in terminate
File "/usr/lib/python3.4/subprocess.py", line 1681, in send_signal
TypeError: an integer is required (got type NoneType)

I fixed this one by adding a general except for proc.terminate and proc.wait

It would be really great when you would merge this improvement. These sporadic tracebacks are really annoying

@codecov-io
Copy link

Codecov Report

Merging #576 into master will increase coverage by 1.35%.

@@            Coverage Diff             @@
##           master     #576      +/-   ##
==========================================
+ Coverage   93.12%   94.47%   +1.35%     
==========================================
  Files          63       63              
  Lines        9932     9937       +5     
==========================================
+ Hits         9249     9388     +139     
+ Misses        683      549     -134
Impacted Files Coverage Δ
git/cmd.py 84.88% <ø> (-0.53%)
git/repo/base.py 96.11% <ø> (+0.24%)
git/test/test_docs.py 100% <ø> (+0.39%)
git/objects/submodule/base.py 94.54% <ø> (+1.45%)
git/remote.py 92.97% <ø> (+1.68%)
git/exc.py 96.36% <ø> (+1.81%)
git/test/test_repo.py 97.39% <ø> (+2.25%)
git/test/test_base.py 98.85% <ø> (+2.29%)
git/test/test_index.py 97.36% <ø> (+3.38%)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 552a0aa...53b576a. Read the comment docs.

@Byron Byron closed this in 88732b6 Feb 25, 2017
@Byron
Copy link
Member

Byron commented Feb 25, 2017

Thanks for the PR. As the code is terrible enough as it is, I believed it would be a better solution to just not try to use TASKKILL unless we are on windows, which should fix your problem.

Maybe this fixes your problem already, and if not, some more exception handling might indeed be needed, just because Python really is a mess when shutting down its own process.

@xsteve
Copy link
Author

xsteve commented Mar 15, 2017

I found some time to test your improvement.
It works a lot better now.

However now I see another class of errors.

I have described them in issue #610

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

Successfully merging this pull request may close these issues.

3 participants