Skip to content

Commit 9bead0e

Browse files
committed
Seems like test_multiprocessing fork deprecation warnings are suppressed.
1 parent 1a20748 commit 9bead0e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ def test_notify(self):
17651765
threading_helper.join_thread(t)
17661766
join_process(p)
17671767

1768+
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
17681769
def test_notify_all(self):
17691770
cond = self.Condition()
17701771
sleeping = self.Semaphore(0)
@@ -1834,6 +1835,7 @@ def test_notify_all(self):
18341835
# NOTE: join_process and join_thread are the same
18351836
threading_helper.join_thread(w)
18361837

1838+
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
18371839
def test_notify_n(self):
18381840
cond = self.Condition()
18391841
sleeping = self.Semaphore(0)
@@ -1974,6 +1976,7 @@ def _test_wait_result(cls, c, pid):
19741976
if pid is not None:
19751977
os.kill(pid, signal.SIGINT)
19761978

1979+
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-135427
19771980
def test_wait_result(self):
19781981
if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
19791982
pid = os.getpid()
@@ -2801,8 +2804,16 @@ class _TestPool(BaseTestCase):
28012804

28022805
@classmethod
28032806
def setUpClass(cls):
2804-
super().setUpClass()
2805-
cls.pool = cls.Pool(4)
2807+
# gh-135427
2808+
# In some of the tests, a forked child forks another child of itself. In that case, using
2809+
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
2810+
# child of child, and a warnings_helper.ignore_warnings exception is raised.
2811+
with warnings.catch_warnings():
2812+
warnings.filterwarnings('ignore',
2813+
message=".*fork.*may lead to deadlocks in the child.*",
2814+
category=DeprecationWarning)
2815+
super().setUpClass()
2816+
cls.pool = cls.Pool(4)
28062817

28072818
@classmethod
28082819
def tearDownClass(cls):
@@ -6982,8 +6993,16 @@ def Pool(cls, *args, **kwds):
69826993

69836994
@classmethod
69846995
def setUpClass(cls):
6985-
super().setUpClass()
6986-
cls.manager = multiprocessing.Manager()
6996+
# gh-135427
6997+
# In some of the tests, a forked child forks another child of itself. In that case, using
6998+
# warnings_helper.ignore_warnings decorator does not actually ignore the warning from that
6999+
# child of child, and a warnings_helper.ignore_warnings exception is raised.
7000+
with warnings.catch_warnings():
7001+
warnings.filterwarnings('ignore',
7002+
message=".*fork.*may lead to deadlocks in the child.*",
7003+
category=DeprecationWarning)
7004+
super().setUpClass()
7005+
cls.manager = multiprocessing.Manager()
69877006

69887007
@classmethod
69897008
def tearDownClass(cls):

0 commit comments

Comments
 (0)