Skip to content

Commit c0ebdf1

Browse files
committed
Use the helper in more setUp methods
1 parent 7ee8c23 commit c0ebdf1

File tree

2 files changed

+5
-40
lines changed

2 files changed

+5
-40
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,14 +3577,7 @@ def recv(self):
35773577
class TestManagerExceptions(unittest.TestCase):
35783578
# Issue 106558: Manager exceptions avoids creating cyclic references.
35793579
def setUp(self):
3580-
# gh-135427
3581-
# In some of the tests, a forked child forks another child of itself. In that case, using
3582-
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
3583-
# child of child, and a warnings_helper.ignore_warnings exception is raised.
3584-
with warnings.catch_warnings():
3585-
warnings.filterwarnings('ignore',
3586-
message=".*fork.*may lead to deadlocks in the child.*",
3587-
category=DeprecationWarning)
3580+
with warnings_helper.ignore_fork_in_thread_deprecation_warnings():
35883581
self.mgr = multiprocessing.Manager()
35893582

35903583
def tearDown(self):
@@ -5364,14 +5357,7 @@ def initializer(ns):
53645357
@hashlib_helper.requires_hashdigest('sha256')
53655358
class TestInitializers(unittest.TestCase):
53665359
def setUp(self):
5367-
# gh-135427
5368-
# In some of the tests, a forked child forks another child of itself. In that case, using
5369-
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
5370-
# child of child, and a warnings_helper.ignore_warnings exception is raised.
5371-
with warnings.catch_warnings():
5372-
warnings.filterwarnings('ignore',
5373-
message=".*fork.*may lead to deadlocks in the child.*",
5374-
category=DeprecationWarning)
5360+
with warnings_helper.ignore_fork_in_thread_deprecation_warnings():
53755361
self.mgr = multiprocessing.Manager()
53765362
self.ns = self.mgr.Namespace()
53775363
self.ns.test = 0
@@ -6412,14 +6398,7 @@ def test_list(self):
64126398

64136399
def setUp(self):
64146400
self.manager = self.manager_class()
6415-
# gh-135427
6416-
# In some of the tests, a forked child forks another child of itself. In that case, using
6417-
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
6418-
# child of child, and a warnings_helper.ignore_warnings exception is raised.
6419-
with warnings.catch_warnings():
6420-
warnings.filterwarnings('ignore',
6421-
message=".*fork.*may lead to deadlocks in the child.*",
6422-
category=DeprecationWarning)
6401+
with warnings_helper.ignore_fork_in_thread_deprecation_warnings():
64236402
self.manager.start()
64246403
self.proc = None
64256404

@@ -7128,14 +7107,7 @@ def Pool(cls, *args, **kwds):
71287107

71297108
@classmethod
71307109
def setUpClass(cls):
7131-
# gh-135427
7132-
# In some of the tests, a forked child forks another child of itself. In that case, using
7133-
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
7134-
# child of child, and a warnings_helper.ignore_warnings exception is raised.
7135-
with warnings.catch_warnings():
7136-
warnings.filterwarnings('ignore',
7137-
message=".*fork.*may lead to deadlocks in the child.*",
7138-
category=DeprecationWarning)
7110+
with warnings_helper.ignore_fork_in_thread_deprecation_warnings():
71397111
super().setUpClass()
71407112
cls.manager = multiprocessing.Manager()
71417113

Lib/test/test_concurrent_futures/util.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,7 @@ def setUp(self):
5252
max_workers=self.worker_count,
5353
mp_context=self.get_context(),
5454
**self.executor_kwargs)
55-
# gh-135427
56-
# In some of the tests, a forked child forks another child of itself. In that case, using
57-
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
58-
# child of child, and a warnings_helper.ignore_warnings exception is raised.
59-
with warnings.catch_warnings():
60-
warnings.filterwarnings('ignore',
61-
message=".*fork.*may lead to deadlocks in the child.*",
62-
category=DeprecationWarning)
55+
with warnings_helper.ignore_fork_in_thread_deprecation_warnings():
6356
self.manager = self.get_context().Manager()
6457
else:
6558
self.executor = self.executor_type(

0 commit comments

Comments
 (0)