From 4e57ec975a0bb337371ec2fbb9f2c524f60ba9cb Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 19 Oct 2026 21:25:14 +0900 Subject: [PATCH 1/4] ci: Use sysmon coverage core on Python 3.12 Use coverage.py's sys.monitoring-based measurement core only in the Python 3.12 unit-test matrix jobs. This avoids the significant overhead of the traditional tracing core on Python 3.12 while preserving the existing coverage behavior for every other Python version. The project does not enable branch coverage, which sysmon does not support on Python 3.12. --- .github/workflows/autotest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 8005bda09..66e7b9a12 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -28,6 +28,8 @@ jobs: nmake /f Makefile ./server.exe /RegServer - name: unittest comtypes + env: + COVERAGE_CORE: ${{ matrix.python-version == '3.12' && 'sysmon' || '' }} run: | if ("${{ matrix.support }}" -eq "with 3rd parties") { pip install numpy From f9d43c20ab5792b5709c7c42a3a7c4d080e54a76 Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 19 Oct 2026 21:25:14 +0900 Subject: [PATCH 2/4] ci: avoid canceling remaining unit-test matrix runs on flaky failures Some unit-test combinations are flaky, and canceling the matrix on the first failure makes reruns harder to complete. Keep the in-flight variants running so we can collect the remaining signal and retry only the genuinely broken cases. --- .github/workflows/autotest.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 66e7b9a12..2ef2a226f 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -8,6 +8,10 @@ jobs: unit-tests: runs-on: ${{ matrix.os }} strategy: + # Keep all matrix variants running even when one of the flaky unit-test + # combinations fails. This makes it easier to collect the remaining signal + # and avoids cancelling healthy runs that would otherwise be retried again. + fail-fast: false matrix: os: [windows-latest] python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.15'] From a7372f200785f324bead16ac39f3aa2df516da00 Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 19 Oct 2026 21:25:14 +0900 Subject: [PATCH 3/4] test: temporarily skip flaky test_eval on Python 3.12. Tests that sometimes took more than 20 minutes have certainly become faster, but the "memory leak tests" discussed in #971 still fail randomly. As a temporary workaround, skip `TestInproc_win32com.test_eval` on Python 3.12 in addition to Python >= 3.14. --- comtypes/test/test_comserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comtypes/test/test_comserver.py b/comtypes/test/test_comserver.py index 13e4f9fc4..e5973aac5 100644 --- a/comtypes/test/test_comserver.py +++ b/comtypes/test/test_comserver.py @@ -141,7 +141,7 @@ class TestInproc_win32com(BaseServerTest, unittest.TestCase): def create_object(self): return Dispatch("TestComServerLib.TestComServer") - if sys.version_info >= (3, 14): + if sys.version_info >= (3, 14) or sys.version_info[:2] == (3, 12): @unittest.skip("Fails occasionally with a memory leak on INPROC.") def test_eval(self): From f026043f05fb9f7e6210dc0b20fafcb98d5d4f05 Mon Sep 17 00:00:00 2001 From: junkmd Date: Mon, 19 Oct 2026 21:32:19 +0900 Subject: [PATCH 4/4] ci: update comments. --- .github/workflows/autotest.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 2ef2a226f..60b25c7f5 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -9,8 +9,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: # Keep all matrix variants running even when one of the flaky unit-test - # combinations fails. This makes it easier to collect the remaining signal - # and avoids cancelling healthy runs that would otherwise be retried again. + # combinations fails. This makes it easier to collect the remaining + # signal and avoids cancelling healthy runs. fail-fast: false matrix: os: [windows-latest] @@ -33,6 +33,11 @@ jobs: ./server.exe /RegServer - name: unittest comtypes env: + # The normal coverage core uses `sys.settrace`. In Python 3.12, this + # kind of tracing is very slow. `sysmon` uses Python's newer + # `sys.monitoring` API. + # It gets line events from Python with less extra work, so the test + # job can finish faster. COVERAGE_CORE: ${{ matrix.python-version == '3.12' && 'sysmon' || '' }} run: | if ("${{ matrix.support }}" -eq "with 3rd parties") {