@@ -1984,9 +1984,9 @@ def test_module_state_shared_in_global(self):
19841984 @unittest .skipUnless (hasattr (os , "pipe" ), "requires os.pipe()" )
19851985 @requires_subinterpreters
19861986 def test_pending_call_creates_thread_subinterpreter (self ):
1987- interpreters = import_helper .import_module ("concurrent.interpreters" )
1988- r , w = os .pipe ()
1987+ # For better isolation, run the entire test in a different subprocess.
19891988 source = f"""if True:
1989+ code = '''if True:
19901990 import _testinternalcapi
19911991 import threading
19921992 import time
@@ -1995,9 +1995,7 @@ def test_pending_call_creates_thread_subinterpreter(self):
19951995
19961996 def output():
19971997 time.sleep(1)
1998- os.write({ w } , b"x")
1999- os.close({ w } )
2000-
1998+ print("x")
20011999
20022000 def callback():
20032001 threading.Thread(target=output).start()
@@ -2007,15 +2005,19 @@ def create_pending_call():
20072005 time.sleep(1)
20082006 _testinternalcapi.simple_pending_call(callback)
20092007
2010-
20112008 threading.Thread(target=create_pending_call).start()
2012- """
2009+ '''
2010+
2011+ import concurrent.interpreters as interpreters
2012+
20132013 interp = interpreters.create()
2014- interp .exec (source )
2014+ interp.exec(code )
20152015 interp.close()
2016- data = os .read (r , 1 )
2017- self .assertEqual (data , b"x" )
2018- os .close (r )
2016+ """
2017+ rc , out , err = assert_python_ok ('-c' , source )
2018+ self .assertEqual (rc , 0 )
2019+ self .assertEqual (out , b"x\n " )
2020+ self .assertEqual (err , b"" )
20192021
20202022
20212023@requires_subinterpreters
0 commit comments