Skip to content

Commit 574e91c

Browse files
committed
pythongh-126434: Start fix tests when using use_dedicated_thread=True by defaultˆ
1 parent 5a43697 commit 574e91c

12 files changed

+23
-8
lines changed

Lib/signal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _log_missing_signal_handler(signo):
7777
str_name = x.name
7878
logger.warning('Handler for signal.%s (%d) was not found.', str_name, signo)
7979

80-
def _stop_signal_thread():
80+
def stop_signal_thread():
8181
global _signal_thread, _signal_queue
8282
if _signal_thread is not None:
8383
_signal_queue.put('STOP_SIGNAL_HANDLER')
@@ -115,7 +115,7 @@ def decorator(wrapper):
115115
return wrapper
116116
return decorator
117117

118-
def signal(signalnum, handler, use_dedicated_thread=False):
118+
def signal(signalnum, handler, use_dedicated_thread=True):
119119
if use_dedicated_thread:
120120
assert threading.current_thread() is threading.main_thread()
121121
global _signo_to_handler

Lib/test/test_asyncio/test_base_events.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import errno
55
import math
66
import platform
7+
import signal
78
import socket
89
import sys
910
import threading
@@ -26,6 +27,7 @@
2627

2728
def tearDownModule():
2829
asyncio.set_event_loop_policy(None)
30+
signal.stop_signal_thread()
2931

3032

3133
def mock_socket_module():

Lib/test/test_asyncio/test_context.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import asyncio
22
import decimal
33
import unittest
4+
import signal
45

56

67
def tearDownModule():
78
asyncio.set_event_loop_policy(None)
9+
signal.stop_signal_thread()
810

911

1012
@unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")

Lib/test/test_asyncio/test_futures2.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import contextvars
44
import traceback
55
import unittest
6+
import signal
67
from asyncio import tasks
78

89

910
def tearDownModule():
1011
asyncio.set_event_loop_policy(None)
12+
signal.stop_signal_thread()
1113

1214

1315
class FutureTests:

Lib/test/test_asyncio/test_locks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Tests for locks.py"""
2-
2+
import signal
33
import unittest
44
from unittest import mock
55
import re
@@ -21,6 +21,7 @@
2121

2222
def tearDownModule():
2323
asyncio.set_event_loop_policy(None)
24+
signal.stop_signal_thread()
2425

2526

2627
class LockTests(unittest.IsolatedAsyncioTestCase):

Lib/test/test_asyncio/test_queues.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Tests for queues.py"""
22

33
import asyncio
4+
import signal
45
import unittest
56
from types import GenericAlias
67

78

89
def tearDownModule():
910
asyncio.set_event_loop_policy(None)
10-
11+
signal.stop_signal_thread()
1112

1213
class QueueBasicTests(unittest.IsolatedAsyncioTestCase):
1314

Lib/test/test_asyncio/test_runners.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
def tearDownModule():
1515
asyncio.set_event_loop_policy(None)
16+
signal.stop_signal_thread()
1617

1718

1819
def interrupt_self():

Lib/test/test_asyncio/test_server.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import os
3+
import signal
34
import socket
45
import time
56
import threading
@@ -12,6 +13,7 @@
1213

1314
def tearDownModule():
1415
asyncio.set_event_loop_policy(None)
16+
signal.stop_signal_thread()
1517

1618

1719
class BaseStartServer(func_tests.FunctionalTestCaseMixin):

Lib/test/test_asyncio/test_staggered.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import signal
23
import unittest
34
from asyncio.staggered import staggered_race
45

@@ -9,6 +10,7 @@
910

1011
def tearDownModule():
1112
asyncio.set_event_loop_policy(None)
13+
signal.stop_signal_thread()
1214

1315

1416
class StaggeredTests(unittest.IsolatedAsyncioTestCase):

Lib/test/test_asyncio/test_taskgroups.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Adapted with permission from the EdgeDB project;
22
# license: PSFL.
3-
3+
import signal
44
import sys
55
import gc
66
import asyncio
@@ -15,7 +15,7 @@
1515
# To prevent a warning "test altered the execution environment"
1616
def tearDownModule():
1717
asyncio.set_event_loop_policy(None)
18-
18+
signal.stop_signal_thread()
1919

2020
class MyExc(Exception):
2121
pass

Lib/test/test_asyncio/test_threads.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for asyncio/threads.py"""
22

33
import asyncio
4+
import signal
45
import unittest
56

67
from contextvars import ContextVar
@@ -9,7 +10,7 @@
910

1011
def tearDownModule():
1112
asyncio.set_event_loop_policy(None)
12-
13+
signal.stop_signal_thread()
1314

1415
class ToThreadTests(unittest.IsolatedAsyncioTestCase):
1516
async def test_to_thread(self):

Lib/test/test_asyncio/test_timeouts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Tests for asyncio/timeouts.py"""
2-
2+
import signal
33
import unittest
44
import time
55

@@ -10,6 +10,7 @@
1010

1111
def tearDownModule():
1212
asyncio.set_event_loop_policy(None)
13+
signal.stop_signal_thread()
1314

1415
class TimeoutTests(unittest.IsolatedAsyncioTestCase):
1516

0 commit comments

Comments
 (0)