Title: BrokenPipeError on KeyboardInterrupt · Issue #427 · gitpython-developers/GitPython · GitHub
Open Graph Title: BrokenPipeError on KeyboardInterrupt · Issue #427 · gitpython-developers/GitPython
X Title: BrokenPipeError on KeyboardInterrupt · Issue #427 · gitpython-developers/GitPython
Description: I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to newer versions of GitPython. Consider t...
Open Graph Description: I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to...
X Description: I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/427
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BrokenPipeError on KeyboardInterrupt","articleBody":"I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to newer versions of GitPython. Consider the following snippet (assumes a git repository on the current directory):\n\n``` [python]\nimport time\nfrom git import Repo, TagReference\n\nrepository = Repo('.')\ncurrent_commit = repository.head.commit\ntag_object = TagReference.create(repository, 'test', message='msg')\n\ntry:\n for i in range(10):\n time.sleep(1)\n\nexcept KeyboardInterrupt:\n print(\"Interrupted. Exiting gracefully...\")\n\ndata = tag_object.tag.message\n```\n\nIf you interrupt (Ctrl+C) the loop, then the last statement fails with a broken pipe exception (full stack trace below). If the code is _not_ interrupted everything succeeds. Also removing the `current_commit = repository.head.commit` line, makes the problem go away, even if you interrupt a loop.\n\nI presume that it has to do with the handling of the SIGTERM emitted with a Ctrl+C, but I am not sure if this is true.\n\nThe stack trace:\n\n```\nTraceback (most recent call last):\n File \"./bugreplicate.py\", line 15, in \u003cmodule\u003e\n data = tag_object.tag.message\n File \"/usr/local/lib/python2.7/dist-packages/git/refs/tag.py\", line 40, in tag\n obj = self.object\n File \"/usr/local/lib/python2.7/dist-packages/git/refs/symbolic.py\", line 176, in _get_object\n return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))\n File \"/usr/local/lib/python2.7/dist-packages/git/objects/base.py\", line 65, in new_from_sha\n oinfo = repo.odb.info(sha1)\n File \"/usr/local/lib/python2.7/dist-packages/git/db.py\", line 40, in info\n hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))\n File \"/usr/local/lib/python2.7/dist-packages/git/cmd.py\", line 984, in get_object_header\n return self.__get_object_header(cmd, ref)\n File \"/usr/local/lib/python2.7/dist-packages/git/cmd.py\", line 972, in __get_object_header\n cmd.stdin.flush()\nIOError: [Errno 32] Broken pipe\n```\n\nSome more context: I am using GitPython for `experimenter` [link](https://github.com/mallamanis/experimenter) and need a way to handle `KeyboardInterruption`s. When a Ctrl+C is pressed, I want to be able to safely store data into the git repository.\n","author":{"url":"https://github.com/mallamanis","@type":"Person","name":"mallamanis"},"datePublished":"2016-05-06T13:02:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/427/GitPython/issues/427"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9a6ca5d7-7e23-4002-c941-c2f5e04b437c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D55C:1BBF4:111BC40:1892667:6A58E685 |
| html-safe-nonce | f47e5f9cbd0c48d22901fd42b3cb44861466c490a576563e5a8bcca714551384 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTVDOjFCQkY0OjExMUJDNDA6MTg5MjY2Nzo2QTU4RTY4NSIsInZpc2l0b3JfaWQiOiI0MjEwNTg4MTQ2OTQ4Njk1Njg1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | edff849d1f455a0a8fa1577ab2fb278707740182cfc77a5131940daf38960a0b |
| hovercard-subject-tag | issue:153446002 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/427/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c3aa33e1c09857eb5aae4577699bd5890ddccc461bb819419381edbcbd54760a/gitpython-developers/GitPython/issues/427 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c3aa33e1c09857eb5aae4577699bd5890ddccc461bb819419381edbcbd54760a/gitpython-developers/GitPython/issues/427 |
| og:image:alt | I am using the latest GitPython on pip and I have bumped into a weird behavior, that seems to be buggy. I have replicated the behavior both with Python 2.7 and 3.4 and has emerged after updating to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mallamanis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width