Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ Tools/patchcheck/ @AA-Turner
# ----------------------------------------------------------------------------

# Autotools
configure* @erlend-aasland @corona10 @AA-Turner
Makefile.pre.in @erlend-aasland @AA-Turner
Modules/Setup* @erlend-aasland @AA-Turner
configure* @erlend-aasland @corona10 @AA-Turner @emmatyping
Makefile.pre.in @erlend-aasland @AA-Turner @emmatyping
Modules/Setup* @erlend-aasland @AA-Turner @emmatyping
Modules/makesetup @emmatyping
Tools/build/regen-configure.sh @AA-Turner


Expand Down Expand Up @@ -157,16 +158,16 @@ Lib/_osx_support.py @python/macos-team
Lib/test/test__osx_support.py @python/macos-team

# WebAssembly
Tools/wasm/README.md @brettcannon @freakboy3742
Tools/wasm/README.md @brettcannon @freakboy3742 @emmatyping

# WebAssembly (Emscripten)
Tools/wasm/config.site-wasm32-emscripten @freakboy3742
Tools/wasm/emscripten @freakboy3742
Tools/wasm/config.site-wasm32-emscripten @freakboy3742 @emmatyping
Tools/wasm/emscripten @freakboy3742 @emmatyping

# WebAssembly (WASI)
Tools/wasm/wasi-env @brettcannon
Tools/wasm/wasi.py @brettcannon
Tools/wasm/wasi @brettcannon
Tools/wasm/wasi-env @brettcannon @emmatyping
Tools/wasm/wasi.py @brettcannon @emmatyping
Tools/wasm/wasi @brettcannon @emmatyping

# Windows
PC/ @python/windows-team
Expand Down Expand Up @@ -603,9 +604,9 @@ Lib/test/test_zipfile/_path/ @jaraco
Lib/zipfile/_path/ @jaraco

# Zstandard
Lib/compression/zstd/ @AA-Turner
Lib/test/test_zstd.py @AA-Turner
Modules/_zstd/ @AA-Turner
Lib/compression/zstd/ @AA-Turner @emmatyping
Lib/test/test_zstd.py @AA-Turner @emmatyping
Modules/_zstd/ @AA-Turner @emmatyping

# ----------------------------------------------------------------------------

Expand Down
9 changes: 5 additions & 4 deletions Lib/multiprocessing/forkserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ def ensure_running(self):
cmd = ('from multiprocessing.forkserver import main; ' +
'main(%d, %d, %r, **%r)')

main_kws = {}
if self._preload_modules:
desired_keys = {'main_path', 'sys_path'}
data = spawn.get_preparation_data('ignore')
main_kws = {x: y for x, y in data.items() if x in desired_keys}
else:
main_kws = {}
if 'sys_path' in data:
main_kws['sys_path'] = data['sys_path']
if 'init_main_from_path' in data:
main_kws['main_path'] = data['init_main_from_path']

with socket.socket(socket.AF_UNIX) as listener:
address = connection.arbitrary_address('AF_UNIX')
Expand Down
4 changes: 4 additions & 0 deletions Lib/multiprocessing/popen_spawn_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def _launch(self, process_obj):
self._fds.extend([child_r, child_w])
self.pid = util.spawnv_passfds(spawn.get_executable(),
cmd, self._fds)
os.close(child_r)
child_r = None
os.close(child_w)
child_w = None
self.sentinel = parent_r
with open(parent_w, 'wb', closefd=False) as f:
f.write(fp.getbuffer())
Expand Down
12 changes: 12 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7028,6 +7028,18 @@ def child():
self.assertEqual(q.get_nowait(), "done")
close_queue(q)

def test_preload_main(self):
# gh-126631: Check that __main__ can be pre-loaded
if multiprocessing.get_start_method() != "forkserver":
self.skipTest("forkserver specific test")

name = os.path.join(os.path.dirname(__file__), 'mp_preload_main.py')
_, out, err = test.support.script_helper.assert_python_ok(name)
self.assertEqual(err, b'')

# The trailing empty string comes from split() on output ending with \n
out = out.decode().split("\n")
self.assertEqual(out, ['__main__', '__mp_main__', 'f', 'f', ''])

#
# Mixins
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/list_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def test_init(self):
self.assertEqual(a, b)

def test_getitem_error(self):
a = []
a = self.type2test([])
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a']

def test_setitem_error(self):
a = []
a = self.type2test([])
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a'] = "python"
Expand Down Expand Up @@ -561,7 +561,7 @@ def test_constructor_exception_handling(self):
class F(object):
def __iter__(self):
raise KeyboardInterrupt
self.assertRaises(KeyboardInterrupt, list, F())
self.assertRaises(KeyboardInterrupt, self.type2test, F())

def test_exhausted_iterator(self):
a = self.type2test([1, 2, 3])
Expand Down
14 changes: 14 additions & 0 deletions Lib/test/mp_preload_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import multiprocessing

print(f"{__name__}")

def f():
print("f")

if __name__ == "__main__":
ctx = multiprocessing.get_context("forkserver")
ctx.set_forkserver_preload(['__main__'])
for _ in range(2):
p = ctx.Process(target=f)
p.start()
p.join()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix potential hang in ``multiprocessing.popen_spawn_posix`` that can happen
when the child proc dies early by closing the child fds right away.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :mod:`multiprocessing` ``forkserver`` bug which prevented ``__main__``
from being preloaded.
Loading