René's URL Explorer Experiment


Title: Remote.fetch(kill_after_timeout=...) does not stop git when it writes nothing more to stderr · Issue #2276 · gitpython-developers/GitPython · GitHub

Open Graph Title: Remote.fetch(kill_after_timeout=...) does not stop git when it writes nothing more to stderr · Issue #2276 · gitpython-developers/GitPython

X Title: Remote.fetch(kill_after_timeout=...) does not stop git when it writes nothing more to stderr · Issue #2276 · gitpython-developers/GitPython

Description: Question The documentation for Remote.fetch describes kill_after_timeout as "a timeout in seconds for the git command, after which the process should be killed". When git writes nothing more to stderr after the deadline, which is what ha...

Open Graph Description: Question The documentation for Remote.fetch describes kill_after_timeout as "a timeout in seconds for the git command, after which the process should be killed". When git writes nothing more to std...

X Description: Question The documentation for Remote.fetch describes kill_after_timeout as "a timeout in seconds for the git command, after which the process should be killed". When git writes nothing m...

Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2276

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remote.fetch(kill_after_timeout=...) does not stop git when it writes nothing more to stderr","articleBody":"### Question\n\nThe documentation for `Remote.fetch` describes `kill_after_timeout` as \"a timeout in seconds for the git command, after which the process should be killed\". When git writes nothing more to stderr after the deadline, which is what happens when a remote stalls, the call never returns and the `git fetch` process keeps running. Is this a known limitation, or a bug?\n\n### Context\n\nWe use `kill_after_timeout` to put an upper bound on how long a fetch can run.\n\n### Reproduction\n\n```python\nimport socket\nimport tempfile\nimport threading\nimport time\nfrom pathlib import Path\n\nfrom git import Repo\nfrom git.exc import GitCommandError\n\n# A remote that accepts the connection and never answers.\nserver = socket.socket()\nserver.bind((\"127.0.0.1\", 0))\nserver.listen()\nport = server.getsockname()[1]\nheld = []\nthreading.Thread(target=lambda: [held.append(server.accept()[0]) for _ in iter(int, 1)], daemon=True).start()\n\nrepo = Repo.init(Path(tempfile.mkdtemp()))\nrepo.create_remote(\"origin\", f\"git://127.0.0.1:{port}/stalled.git\")\n\nstarted = time.monotonic()\ntry:\n    repo.remotes.origin.fetch(kill_after_timeout=3)\n    print(\"returned\")\nexcept GitCommandError as exc:\n    print(f\"GitCommandError after {time.monotonic() - started:.1f}s: {exc}\")\n```\n\n**Expected:** a `GitCommandError` after about 3 seconds.\n\n**Actual:** the call never returns, and `git fetch -v -- origin` keeps running until it is killed by hand.\n\n**Reproduced with:**\n- GitPython 3.2.0, git 2.47.3, Python 3.13, Linux (the `python:3.13` Docker image)\n- GitPython 3.1.61 and 3.2.0, git 2.52.0, Python 3.14.7, macOS\n\n### What I think happens\n\n`Remote.fetch` does not pass `kill_after_timeout` to the git command. It passes it to `_get_fetch_info_from_stderr`, and from there to `handle_process_output`. When the stderr pump thread is still alive after the timeout, `handle_process_output` calls `AutoInterrupt._terminate()`. That method closes `stdin`, `stdout` and `stderr` *before* it calls `proc.terminate()`.\n\nThe pump thread is blocked in `read()` on that same stderr stream, so it holds the buffered reader's lock, and `stderr.close()` waits for that lock indefinitely. The process is never signalled. A native stack sample of the stuck process (on macOS) shows exactly that:\n\n- **main thread:** `_io_TextIOWrapper_close` → `_io__Buffered_close` → `_enter_buffered_busy` → `PyThread_acquire_lock_timed`\n- **pump thread:** `_textiowrapper_readline` → `_io__Buffered_read1` → `read`\n\nSo the timeout takes effect only if git writes to stderr after the deadline, which releases the pump thread's read.\n\nThe command-level timeout works for the same remote: `repo.git.fetch(\"origin\", kill_after_timeout=3)` goes through `Git.execute`, whose watchdog sends `SIGKILL`. It raised `GitCommandError` with status -9 after 3.0 seconds, on both platforms.\n\n### A possible fix\n\nSignal the process before closing its streams, either by reordering `_terminate()` or by killing the process in `handle_process_output` before calling `_terminate()`. Once git exits, the write end of the pipe closes, `read()` returns EOF, and the close no longer blocks.\n\nOne caveat, which I have not tested: for `https://` and `ssh` remotes, `git fetch` starts a helper (`git-remote-https` or `ssh`) that inherits its stderr. If only `git fetch` is signalled, a helper stuck on the network may keep the pipe open, and the read may still block. A complete fix might need to signal the children too, as the `Git.execute` watchdog does, or the whole process group. \n\nTwo smaller points, in case they are useful:\n\n- The loop joins each pump thread one after another with the full timeout, so the worst-case wait is the timeout multiplied by the number of pumped streams.\n- `_terminate()` sends `SIGTERM`, while the `Git.execute` watchdog sends `SIGKILL`.\n\n`Remote.pull` and `Remote.push` appear to use the same path, but I have only tested `fetch`.","author":{"url":"https://github.com/ogenstad","@type":"Person","name":"ogenstad"},"datePublished":"2026-10-07T07:07:33Z","url":"https://github.com/gitpython-developers/GitPython/issues/2276"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6f7f6b14-c742-e8f3-52b8-41638ab28733
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA13E:395430:40F095:57D23C:6B00C92E
html-safe-nonce481adfcc9ccc0b83a51647d79881d5c8c5e558aede073e28a8bd55e232032b05
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTNFOjM5NTQzMDo0MEYwOTU6NTdEMjNDOjZCMDBDOTJFIiwidmlzaXRvcl9pZCI6IjkxMzY3MTU2ODc1NjQyMDAyMzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbaa9534cfda52aea455d35b535f1bd81e78ccdaf7a8de2d785588b588ef3dd50
hovercard-subject-tagissue:5740900100
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/2276/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a3112d0f8d5abfc6b3e2bd0b3b21526697d9aa03365ca051876f9815bd12fcc4/gitpython-developers/GitPython/issues/2276
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a3112d0f8d5abfc6b3e2bd0b3b21526697d9aa03365ca051876f9815bd12fcc4/gitpython-developers/GitPython/issues/2276
og:image:altQuestion The documentation for Remote.fetch describes kill_after_timeout as "a timeout in seconds for the git command, after which the process should be killed". When git writes nothing more to std...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameogenstad
hostnamegithub.com
expected-hostnamegithub.com
None98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4
turbo-cache-controlno-preview
go-importgithub.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126087
octolytics-dimension-repository_nwogitpython-developers/GitPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126087
octolytics-dimension-repository_network_root_nwogitpython-developers/GitPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseef013399cf0a3c324bea644a685d7c1e0f06b5b7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/gitpython-developers/GitPython/issues/2276#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F2276
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2FGitPython%2Fissues%2F2276
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=gitpython-developers%2FGitPython
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2276
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2276
Reloadhttps://github.com/gitpython-developers/GitPython/issues/2276
gitpython-developershttps://github.com/gitpython-developers
GitPythonhttps://github.com/gitpython-developers/GitPython
Codehttps://github.com/gitpython-developers/GitPython
Issues1 (1)https://github.com/gitpython-developers/GitPython/issues
Pull requestshttps://github.com/gitpython-developers/GitPython/pulls
Discussionshttps://github.com/gitpython-developers/GitPython/discussions
Actionshttps://github.com/gitpython-developers/GitPython/actions
Security and quality42 (42)https://github.com/gitpython-developers/GitPython/security
Insightshttps://github.com/gitpython-developers/GitPython/insights
https://github.com/gitpython-developers/GitPython
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2276
New issuehttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2276
#2277https://github.com/gitpython-developers/GitPython/pull/2277
Remote.fetch(kill_after_timeout=...) does not stop git when it writes nothing more to stderrhttps://github.com/gitpython-developers/GitPython/issues/2276#top
#2277https://github.com/gitpython-developers/GitPython/pull/2277
https://github.com/ogenstad
ogenstadhttps://github.com/ogenstad
on Oct 7, 2026https://github.com/gitpython-developers/GitPython/issues/2276#issue-5740900100
Byronhttps://github.com/Byron
on Oct 7, 2026https://github.com/gitpython-developers/GitPython/issues/2276#event-32675313749
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/a720bd863861cd70efe4dbadb4821fb5ace288f8
#2276https://github.com/gitpython-developers/GitPython/issues/2276
a720bd8https://github.com/gitpython-developers/GitPython/commit/a720bd863861cd70efe4dbadb4821fb5ace288f8
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/56d071321ff08ce5b34884787b2b37aaa1af4ad4
#2276https://github.com/gitpython-developers/GitPython/issues/2276
56d0713https://github.com/gitpython-developers/GitPython/commit/56d071321ff08ce5b34884787b2b37aaa1af4ad4
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/7823f6b583f0d74c7597eca6d08fdc3beeb7797e
#2276https://github.com/gitpython-developers/GitPython/issues/2276
7823f6bhttps://github.com/gitpython-developers/GitPython/commit/7823f6b583f0d74c7597eca6d08fdc3beeb7797e
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/f1d9f6127b67fd9b4cf68b22947ca0f9b1ae7456
#2276https://github.com/gitpython-developers/GitPython/issues/2276
f1d9f61https://github.com/gitpython-developers/GitPython/commit/f1d9f6127b67fd9b4cf68b22947ca0f9b1ae7456
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/4c0b78e3dd141d492b4372806969abc00b06b1ee
#2276https://github.com/gitpython-developers/GitPython/issues/2276
4c0b78ehttps://github.com/gitpython-developers/GitPython/commit/4c0b78e3dd141d492b4372806969abc00b06b1ee
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/e5822e3d29cbf54500e0bc9128d1c4bb62d0475b
#2276https://github.com/gitpython-developers/GitPython/issues/2276
e5822e3https://github.com/gitpython-developers/GitPython/commit/e5822e3d29cbf54500e0bc9128d1c4bb62d0475b
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/3d1cfe19b1653625568867fe344118204d8d6d86
#2276https://github.com/gitpython-developers/GitPython/issues/2276
3d1cfe1https://github.com/gitpython-developers/GitPython/commit/3d1cfe19b1653625568867fe344118204d8d6d86
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/30b741ca6946722c6b08d8c2da55723cff46fdfa
#2276https://github.com/gitpython-developers/GitPython/issues/2276
30b741chttps://github.com/gitpython-developers/GitPython/commit/30b741ca6946722c6b08d8c2da55723cff46fdfa
fix: stop stalled remote commands when their timeout expires (#2276)https://github.com/gitpython-developers/GitPython/commit/5ba236e9ce085f7fe467d0964682a4375210aa3e
#2276https://github.com/gitpython-developers/GitPython/issues/2276
5ba236ehttps://github.com/gitpython-developers/GitPython/commit/5ba236e9ce085f7fe467d0964682a4375210aa3e
Byronhttps://github.com/Byron
completedhttps://github.com/gitpython-developers/GitPython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2277https://github.com/gitpython-developers/GitPython/pull/2277
on Oct 8, 2026https://github.com/gitpython-developers/GitPython/issues/2276#event-32764222086
https://github.com/ogenstad
ogenstadhttps://github.com/ogenstad
on Oct 8, 2026https://github.com/gitpython-developers/GitPython/issues/2276#issuecomment-6056180436
@Byronhttps://github.com/Byron
Sign up for freehttps://github.com/signup?return_to=https://github.com/gitpython-developers/GitPython/issues/2276
Sign in to commenthttps://github.com/login?return_to=https://github.com/gitpython-developers/GitPython/issues/2276
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.