Skip to content

Commit

Permalink
Check if we're on the main thread when using mock sigterm handler in …
Browse files Browse the repository at this point in the history
…tests (#11552)
  • Loading branch information
serinamarie authored Jan 4, 2024
1 parent 1898227 commit e235cb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/public/flows/test_flow_crashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import asyncio
import os
import signal
import threading
from unittest.mock import ANY, MagicMock

import anyio
Expand Down Expand Up @@ -211,6 +212,8 @@ async def parent_flow():

@pytest.fixture
def mock_sigterm_handler():
if threading.current_thread() != threading.main_thread():
pytest.skip("Can't test signal handlers from a thread")
mock = MagicMock()

def handler(*args, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import signal
import sys
import threading
import time
from functools import partial
from itertools import combinations
Expand Down Expand Up @@ -82,6 +83,8 @@ def test_flow():

@pytest.fixture
def mock_sigterm_handler():
if threading.current_thread() != threading.main_thread():
pytest.skip("Can't test signal handlers from a thread")
mock = MagicMock()

def handler(*args, **kwargs):
Expand Down

0 comments on commit e235cb1

Please sign in to comment.