Skip to content

Commit b58b2ca

Browse files
committed
Replace the generic decorators to ignore deprecation errors with specific decorator to ignore only the fork in thread deprecation warnings
1 parent e1398d8 commit b58b2ca

22 files changed

+227
-227
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 130 additions & 130 deletions
Large diffs are not rendered by default.

Lib/test/test_asyncio/test_unix_events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ async def runner():
11821182
@support.requires_fork()
11831183
class TestFork(unittest.IsolatedAsyncioTestCase):
11841184

1185-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
1185+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
11861186
async def test_fork_not_share_event_loop(self):
11871187
# The forked process should not share the event loop with the parent
11881188
loop = asyncio.get_running_loop()
@@ -1207,7 +1207,7 @@ async def test_fork_not_share_event_loop(self):
12071207
self.assertEqual(result, b'NO LOOP')
12081208
wait_process(pid, exitcode=0)
12091209

1210-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
1210+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
12111211
@hashlib_helper.requires_hashdigest('md5')
12121212
@support.skip_if_sanitizer("TSAN doesn't support threads after fork", thread=True)
12131213
def test_fork_signal_handling(self):
@@ -1255,7 +1255,7 @@ async def func():
12551255
self.assertFalse(parent_handled.is_set())
12561256
self.assertTrue(child_handled.is_set())
12571257

1258-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
1258+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
12591259
@hashlib_helper.requires_hashdigest('md5')
12601260
@support.skip_if_sanitizer("TSAN doesn't support threads after fork", thread=True)
12611261
def test_fork_asyncio_run(self):
@@ -1276,7 +1276,7 @@ async def child_main():
12761276

12771277
self.assertEqual(result.value, 42)
12781278

1279-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
1279+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
12801280
@hashlib_helper.requires_hashdigest('md5')
12811281
@support.skip_if_sanitizer("TSAN doesn't support threads after fork", thread=True)
12821282
def test_fork_asyncio_subprocess(self):

Lib/test/test_builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ def run_child(self, child, terminal_input):
25462546
finally:
25472547
signal.signal(signal.SIGHUP, old_sighup)
25482548

2549-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
2549+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
25502550
def _run_child(self, child, terminal_input):
25512551
r, w = os.pipe() # Pipe test results from child back to parent
25522552
try:

Lib/test/test_concurrent_futures/executor.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class ExecutorTest:
4343

4444
# Executor.shutdown() and context manager usage is tested by
4545
# ExecutorShutdownTest.
46-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
46+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
4747
def test_submit(self):
4848
future = self.executor.submit(pow, 2, 8)
4949
self.assertEqual(256, future.result())
5050

51-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
51+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
5252
def test_submit_keyword(self):
5353
future = self.executor.submit(mul, 2, y=8)
5454
self.assertEqual(16, future.result())
@@ -59,7 +59,7 @@ def test_submit_keyword(self):
5959
with self.assertRaises(TypeError):
6060
self.executor.submit(arg=1)
6161

62-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
62+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
6363
def test_map(self):
6464
self.assertEqual(
6565
list(self.executor.map(pow, range(10), range(10))),
@@ -69,15 +69,15 @@ def test_map(self):
6969
list(self.executor.map(pow, range(10), range(10), chunksize=3)),
7070
list(map(pow, range(10), range(10))))
7171

72-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
72+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
7373
def test_map_exception(self):
7474
i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
7575
self.assertEqual(i.__next__(), (0, 1))
7676
self.assertEqual(i.__next__(), (0, 1))
7777
with self.assertRaises(ZeroDivisionError):
7878
i.__next__()
7979

80-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
80+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
8181
@support.requires_resource('walltime')
8282
def test_map_timeout(self):
8383
results = []
@@ -113,30 +113,30 @@ def test_map_buffersize_value_validation(self):
113113
):
114114
self.executor.map(str, range(4), buffersize=buffersize)
115115

116-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
116+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
117117
def test_map_buffersize(self):
118118
ints = range(4)
119119
for buffersize in (1, 2, len(ints), len(ints) * 2):
120120
with self.subTest(buffersize=buffersize):
121121
res = self.executor.map(str, ints, buffersize=buffersize)
122122
self.assertListEqual(list(res), ["0", "1", "2", "3"])
123123

124-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
124+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
125125
def test_map_buffersize_on_multiple_iterables(self):
126126
ints = range(4)
127127
for buffersize in (1, 2, len(ints), len(ints) * 2):
128128
with self.subTest(buffersize=buffersize):
129129
res = self.executor.map(add, ints, ints, buffersize=buffersize)
130130
self.assertListEqual(list(res), [0, 2, 4, 6])
131131

132-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
132+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
133133
def test_map_buffersize_on_infinite_iterable(self):
134134
res = self.executor.map(str, itertools.count(), buffersize=2)
135135
self.assertEqual(next(res, None), "0")
136136
self.assertEqual(next(res, None), "1")
137137
self.assertEqual(next(res, None), "2")
138138

139-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
139+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
140140
def test_map_buffersize_on_multiple_infinite_iterables(self):
141141
res = self.executor.map(
142142
add,
@@ -156,7 +156,7 @@ def test_map_buffersize_without_iterable(self):
156156
res = self.executor.map(str, buffersize=2)
157157
self.assertIsNone(next(res, None))
158158

159-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
159+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
160160
def test_map_buffersize_when_buffer_is_full(self):
161161
ints = iter(range(4))
162162
buffersize = 2
@@ -168,15 +168,15 @@ def test_map_buffersize_when_buffer_is_full(self):
168168
msg="should have fetched only `buffersize` elements from `ints`.",
169169
)
170170

171-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
171+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
172172
def test_shutdown_race_issue12456(self):
173173
# Issue #12456: race condition at shutdown where trying to post a
174174
# sentinel in the call queue blocks (the queue is full while processes
175175
# have exited).
176176
self.executor.map(str, [2] * (self.worker_count + 1))
177177
self.executor.shutdown()
178178

179-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
179+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
180180
@support.cpython_only
181181
def test_no_stale_references(self):
182182
# Issue #16284: check that the executors don't unnecessarily hang onto
@@ -221,7 +221,7 @@ def test_max_workers_negative(self):
221221
"than 0"):
222222
self.executor_type(max_workers=number)
223223

224-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
224+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
225225
def test_free_reference(self):
226226
# Issue #14406: Result iterator should not keep an internal
227227
# reference to result objects.
@@ -234,7 +234,7 @@ def test_free_reference(self):
234234
if wr() is None:
235235
break
236236

237-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
237+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
238238
def test_swallows_falsey_exceptions(self):
239239
# see gh-132063: Prevent exceptions that evaluate as falsey
240240
# from being ignored.

Lib/test/test_concurrent_futures/test_as_completed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def mul(x, y):
2020

2121

2222
class AsCompletedTests:
23-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
23+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
2424
def test_no_timeout(self):
2525
future1 = self.executor.submit(mul, 2, 21)
2626
future2 = self.executor.submit(mul, 7, 6)
@@ -37,7 +37,7 @@ def test_no_timeout(self):
3737
future1, future2]),
3838
completed)
3939

40-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
40+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
4141
def test_future_times_out(self):
4242
"""Test ``futures.as_completed`` timing out before
4343
completing it's final future."""
@@ -65,7 +65,7 @@ def test_future_times_out(self):
6565
# Check that ``future`` wasn't completed.
6666
self.assertEqual(completed_futures, already_completed)
6767

68-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
68+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
6969
def test_duplicate_futures(self):
7070
# Issue 20367. Duplicate futures should not raise exceptions or give
7171
# duplicate responses.

Lib/test/test_concurrent_futures/test_deadlock.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _fail_on_deadlock(self, executor):
112112
print(f"\nTraceback:\n {tb}", file=sys.__stderr__)
113113
self.fail(f"Executor deadlock:\n\n{tb}")
114114

115-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
115+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
116116
def _check_error(self, error, func, *args, ignore_stderr=False):
117117
# test for deadlock caused by crashes or exiting in a pool
118118
self.executor.shutdown(wait=True)
@@ -201,7 +201,7 @@ def test_exit_during_result_unpickle_in_result_handler(self):
201201
# the result_handler thread
202202
self._check_error(BrokenProcessPool, _return_instance, ExitAtUnpickle)
203203

204-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
204+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
205205
@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
206206
def test_shutdown_deadlock(self):
207207
# Test that the pool calling shutdown do not cause deadlock
@@ -215,7 +215,7 @@ def test_shutdown_deadlock(self):
215215
with self.assertRaises(BrokenProcessPool):
216216
f.result()
217217

218-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
218+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
219219
def test_shutdown_deadlock_pickle(self):
220220
# Test that the pool calling shutdown with wait=False does not cause
221221
# a deadlock if a task fails at pickle after the shutdown call.
@@ -242,7 +242,7 @@ def test_shutdown_deadlock_pickle(self):
242242
# dangling threads
243243
executor_manager.join()
244244

245-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
245+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
246246
@support.skip_if_sanitizer("UBSan: explicit SIGSEV not allowed", ub=True)
247247
def test_crash_big_data(self):
248248
# Test that there is a clean exception instead of a deadlock when a
@@ -259,7 +259,7 @@ def test_crash_big_data(self):
259259

260260
executor.shutdown(wait=True)
261261

262-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
262+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
263263
def test_gh105829_should_not_deadlock_if_wakeup_pipe_full(self):
264264
# Issue #105829: The _ExecutorManagerThread wakeup pipe could
265265
# fill up and block. See: https://github.com/python/cpython/issues/105829

Lib/test/test_concurrent_futures/test_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def setUp(self):
4949
initargs=('initialized',))
5050
super().setUp()
5151

52-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
52+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
5353
def test_initializer(self):
5454
futures = [self.executor.submit(get_init_status)
5555
for _ in range(self.worker_count)]
@@ -76,7 +76,7 @@ def setUp(self):
7676
self.executor_kwargs = dict(initializer=init_fail)
7777
super().setUp()
7878

79-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
79+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
8080
def test_initializer(self):
8181
with self._assert_logged('ValueError: error in initializer'):
8282
try:

Lib/test/test_concurrent_futures/test_process_pool.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_max_workers_too_large(self):
4949
"max_workers must be <= 61"):
5050
futures.ProcessPoolExecutor(max_workers=62)
5151

52-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
52+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
5353
def test_killed_child(self):
5454
# When a child process is abruptly terminated, the whole pool gets
5555
# "broken".
@@ -62,7 +62,7 @@ def test_killed_child(self):
6262
# Submitting other jobs fails as well.
6363
self.assertRaises(BrokenProcessPool, self.executor.submit, pow, 2, 8)
6464

65-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
65+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
6666
def test_map_chunksize(self):
6767
def bad_map():
6868
list(self.executor.map(pow, range(40), range(40), chunksize=-1))
@@ -83,7 +83,7 @@ def bad_map():
8383
def _test_traceback(cls):
8484
raise RuntimeError(123) # some comment
8585

86-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
86+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
8787
def test_traceback(self):
8888
# We want ensure that the traceback from the child process is
8989
# contained in the traceback raised in the main process.
@@ -106,7 +106,7 @@ def test_traceback(self):
106106
self.assertIn('raise RuntimeError(123) # some comment',
107107
f1.getvalue())
108108

109-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
109+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
110110
@hashlib_helper.requires_hashdigest('md5')
111111
def test_ressources_gced_in_workers(self):
112112
# Ensure that argument for a job are correctly gc-ed after the job
@@ -127,7 +127,7 @@ def test_ressources_gced_in_workers(self):
127127
mgr.shutdown()
128128
mgr.join()
129129

130-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
130+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
131131
def test_saturation(self):
132132
executor = self.executor
133133
mp_context = self.get_context()
@@ -213,7 +213,7 @@ def test_max_tasks_early_shutdown(self):
213213
for i, future in enumerate(futures):
214214
self.assertEqual(future.result(), mul(i, i))
215215

216-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
216+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
217217
def test_python_finalization_error(self):
218218
# gh-109047: Catch RuntimeError on thread creation
219219
# during Python finalization.
@@ -264,7 +264,7 @@ def test_force_shutdown_workers_invalid_op(self):
264264
executor._force_shutdown,
265265
operation='invalid operation'),
266266

267-
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
267+
@warnings_helper.ignore_fork_in_thread_deprecation_warnings # gh-135427
268268
@parameterize(*FORCE_SHUTDOWN_PARAMS)
269269
def test_force_shutdown_workers(self, function_name):
270270
manager = self.get_context().Manager()

0 commit comments

Comments
 (0)