FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Document MONO_THREADS_SUSPEND and use throughout CI (#2747) · pythonnet/pythonnet@deca529 · GitHub

Repository navigation

Commit deca529

Browse files
authored
Document MONO_THREADS_SUSPEND and use throughout CI (#2747)
1 parent b9de39f commit deca529

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252

5353
env:
5454
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
55+
# Apply to every Mono host, including pytest and the .NET Python test runner.
56+
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
5557
steps:
5658
- name: Checkout code
5759
uses: actions/checkout@v7
@@ -84,8 +86,6 @@ jobs:
8486
- name: Embedding tests (Mono/.NET Framework)
8587
if: always()
8688
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net472 --logger "console;verbosity=detailed" src/embed_tests/
87-
env:
88-
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
8989

9090
- name: Embedding tests (.NET Core)
9191
if: always()
@@ -97,7 +97,7 @@ jobs:
9797

9898
- name: Python Tests (Mono)
9999
if: always()
100-
run: pytest --runtime mono
100+
run: uv run pytest --runtime mono -v -o faulthandler_timeout=60
101101

102102
- name: Python Tests (.NET Framework)
103103
if: ${{ matrix.os.category == 'windows' }}

‎doc/source/threading.rst‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ Forgetting this is the most common pythonnet threading bug. Symptoms range
9393
from immediate segfaults to subtle refcount corruption that crashes much
9494
later.
9595

96+
Mono thread suspension
97+
----------------------
98+
99+
On Linux and macOS, Mono's cooperative/hybrid thread suspension can hang
100+
when Python and managed threads interact. If affected, set
101+
``MONO_THREADS_SUSPEND=preemptive`` before starting the process, as described
102+
in `mono/mono#21466 <https://github.com/mono/mono/issues/21466>`_.
103+
CI uses this workaround for both embedding and Python-hosted tests.
104+
105+
To run the Mono Python tests with per-test output and a Python thread
106+
stack dump if a test takes longer than 60 seconds::
107+
108+
MONO_THREADS_SUSPEND=preemptive uv run pytest --runtime mono -v -o faulthandler_timeout=60
109+
96110
Reference counting and finalizers
97111
---------------------------------
98112

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL