Skip to content

Commit

Permalink
pythongh-126434: Start fix tests when using use_dedicated_thread=True…
Browse files Browse the repository at this point in the history
… by defaultˆ
  • Loading branch information
ivarref committed Dec 3, 2024
1 parent 5a43697 commit 574e91c
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Lib/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _log_missing_signal_handler(signo):
str_name = x.name
logger.warning('Handler for signal.%s (%d) was not found.', str_name, signo)

def _stop_signal_thread():
def stop_signal_thread():
global _signal_thread, _signal_queue
if _signal_thread is not None:
_signal_queue.put('STOP_SIGNAL_HANDLER')
Expand Down Expand Up @@ -115,7 +115,7 @@ def decorator(wrapper):
return wrapper
return decorator

def signal(signalnum, handler, use_dedicated_thread=False):
def signal(signalnum, handler, use_dedicated_thread=True):
if use_dedicated_thread:
assert threading.current_thread() is threading.main_thread()
global _signo_to_handler
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import errno
import math
import platform
import signal
import socket
import sys
import threading
Expand All @@ -26,6 +27,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


def mock_socket_module():
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_context.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import asyncio
import decimal
import unittest
import signal


def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


@unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_futures2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import contextvars
import traceback
import unittest
import signal
from asyncio import tasks


def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


class FutureTests:
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_locks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for locks.py"""

import signal
import unittest
from unittest import mock
import re
Expand All @@ -21,6 +21,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


class LockTests(unittest.IsolatedAsyncioTestCase):
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_queues.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Tests for queues.py"""

import asyncio
import signal
import unittest
from types import GenericAlias


def tearDownModule():
asyncio.set_event_loop_policy(None)

signal.stop_signal_thread()

class QueueBasicTests(unittest.IsolatedAsyncioTestCase):

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_asyncio/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


def interrupt_self():
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
import signal
import socket
import time
import threading
Expand All @@ -12,6 +13,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


class BaseStartServer(func_tests.FunctionalTestCaseMixin):
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_asyncio/test_staggered.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import signal
import unittest
from asyncio.staggered import staggered_race

Expand All @@ -9,6 +10,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()


class StaggeredTests(unittest.IsolatedAsyncioTestCase):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_asyncio/test_taskgroups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Adapted with permission from the EdgeDB project;
# license: PSFL.

import signal
import sys
import gc
import asyncio
Expand All @@ -15,7 +15,7 @@
# To prevent a warning "test altered the execution environment"
def tearDownModule():
asyncio.set_event_loop_policy(None)

signal.stop_signal_thread()

class MyExc(Exception):
pass
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_threads.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for asyncio/threads.py"""

import asyncio
import signal
import unittest

from contextvars import ContextVar
Expand All @@ -9,7 +10,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)

signal.stop_signal_thread()

class ToThreadTests(unittest.IsolatedAsyncioTestCase):
async def test_to_thread(self):
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_timeouts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for asyncio/timeouts.py"""

import signal
import unittest
import time

Expand All @@ -10,6 +10,7 @@

def tearDownModule():
asyncio.set_event_loop_policy(None)
signal.stop_signal_thread()

class TimeoutTests(unittest.IsolatedAsyncioTestCase):

Expand Down

0 comments on commit 574e91c

Please sign in to comment.