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

Rungc.collect() twice intest_rename on Python 3.12#2109

Merged
EliahKagan merged 1 commit intogitpython-developers:mainfrom
EliahKagan:312-more-gc
Mar 9, 2026
Merged

Rungc.collect() twice intest_rename on Python 3.12#2109
EliahKagan merged 1 commit intogitpython-developers:mainfrom
EliahKagan:312-more-gc

Conversation

@EliahKagan
Copy link
Member

@EliahKaganEliahKagan commentedMar 9, 2026
edited
Loading

Recently, the conditionalgc.collect() step for Python >= 3.12 inTestSubmodule.test_rename is often insufficient. This has mainly been seen in #2248. For example:

https://github.com/gitpython-developers/GitPython/actions/runs/22864869684/job/66331124651?pr=2106#step:12:620

In principle, there can be situations with finalizers where a cycle is only collectable due to finalization that happened due to a previous collection. Therefore, there is occasionally a benefit to collecting twice. This does that, in the hope that it will help.

As expanded on in my self-review comment below, I hope this is temporary, at least in this exact form.

Recently, the conditional `gc.collect()` step for Python >= 3.12 in`TestSubmodule.test_rename` is often insufficient. This has mainlybeen seen in #2248. For example:https://github.com/gitpython-developers/GitPython/actions/runs/22864869684/job/66331124651?pr=2106#step:12:620In principle, there can be situations with finalizers where a cycleis only collectable due to finalization that happened due to aprevious collection. Therefore, there is occasionally a benefit tocollecting twice. This does that, in the hope that it will help.
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

Improves test stability on Python 3.12+ (especially Windows) by increasing the likelihood that cyclic garbage with finalizers is fully collected before proceeding with submodule rename assertions.

Changes:

  • Callgc.collect() twice on Windows + Python 3.12+ inTestSubmodule.test_rename.
  • Add an inline note explaining why a second collection can help.

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

You can also share your feedback on Copilot code review.Take the survey.

@EliahKaganEliahKagan marked this pull request as ready for reviewMarch 9, 2026 17:46
@EliahKaganEliahKagan merged commit82b7065 intogitpython-developers:mainMar 9, 2026
31 checks passed
@EliahKaganEliahKagan deleted the 312-more-gc branchMarch 9, 2026 17:46
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull requestMar 9, 2026
As discussed ingitpython-developers#2005 andgitpython-developers#2011, we had not been doing this before.Conditions have changed in two relevant ways:- The free-threaded interpreter has been around longer and it sees  more use.- The macOS runners are very fast now.The specific motivations for doing this now are:- In view of the condition described ingitpython-developers#2109 and how the change  there seems to have helped with it, there's some reason to think  *patch* versions of Python sometimes affect GitPython in ways it  makes possibly unfounded assumptions about the effect of garbage  collection. This mainly affects Windows and it is not specific to  free-threaded builds. However, in principle we could also see  assumptions violated in tests we think always work on Unix-like  operating systems, due to differences in how garbage collection  works in free-threaded interpreters. Therefore, the assumption  that this only needs to be tested occasionally is not as well  founded I assumed when I suggested testing it only on GNU/Linux.- We may add 3.14 jobs to CI soon, and it's useful to be able to  see how both free-threaded interpreters work on CI, as well as to  confirm for at least a short while that they are continuing to  work as expected.This macOS free-threaded interpreter CI jobs could be disabled oncemore if necessary, or if they're found to make CI complete slowerin PRs by even a small amount so long as they don't seem to besurfacing anything.
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull requestMar 9, 2026
As discussed ingitpython-developers#2005 andgitpython-developers#2011, we had not been doing this before.Conditions have changed in two relevant ways:- The free-threaded interpreter has been around longer and it sees  more use.- The macOS runners are very fast now.The specific motivations for doing this now are:- In view of the condition described ingitpython-developers#2109 and how the change  there seems to have helped with it, there's some reason to think  *patch* versions of Python sometimes affect GitPython in ways it  makes possibly unfounded assumptions about the effect of garbage  collection. This mainly affects Windows and it is not specific to  free-threaded builds. However, in principle we could also see  assumptions violated in tests we think always work on Unix-like  operating systems, due to differences in how garbage collection  works in free-threaded interpreters. Therefore, the assumption  that this only needs to be tested occasionally is not as well  founded I assumed when I suggested testing it only on GNU/Linux.- We may add 3.14 jobs to CI soon, and it's useful to be able to  see how both free-threaded interpreters work on CI, as well as to  confirm for at least a short while that they are continuing to  work as expected.This macOS free-threaded interpreter CI jobs could be disabled oncemore if necessary, or if they're found to make CI complete slowerin PRs by even a small amount so long as they don't seem to besurfacing anything.
EliahKagan added a commit to EliahKagan/GitPython that referenced this pull requestMar 9, 2026
As discussed ingitpython-developers#2005 andgitpython-developers#2011, we had not been doing this before.Conditions have changed in two relevant ways:- The free-threaded interpreter has been around longer and it sees  more use.- The macOS runners are very fast now.The specific motivations for doing this now are:- In view of the condition described ingitpython-developers#2109 and how the change  there seems to have helped with it, there's some reason to think  *patch* versions of Python sometimes affect GitPython in ways it  makes possibly unfounded assumptions about the effect of garbage  collection. This mainly affects Windows and it is not specific to  free-threaded builds. However, in principle we could also see  assumptions violated in tests we think always work on Unix-like  operating systems, due to differences in how garbage collection  works in free-threaded interpreters. Therefore, the assumption  that this only needs to be tested occasionally is not as well  founded I assumed when I suggested testing it only on GNU/Linux.- We may add 3.14 jobs to CI soon, and it's useful to be able to  see how both free-threaded interpreters work on CI, as well as to  confirm for at least a short while that they are continuing to  work as expected.This macOS free-threaded interpreter CI jobs could be disabled oncemore if necessary, or if they're found to make CI complete slowerin PRs by even a small amount so long as they don't seem to besurfacing anything.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@EliahKagan

[8]ページ先頭

©2009-2026 Movatter.jp