mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25764: Preserve subprocess fork exception when preexec_fn used
Also fix handling of failure to release the import lock.
This commit is contained in:
parent
c7217d7c22
commit
afdd51343c
3 changed files with 37 additions and 17 deletions
|
@ -1416,6 +1416,22 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
if not enabled:
|
||||
gc.disable()
|
||||
|
||||
def test_preexec_fork_failure(self):
|
||||
# The internal code did not preserve the previous exception when
|
||||
# re-enabling garbage collection
|
||||
try:
|
||||
from resource import getrlimit, setrlimit, RLIMIT_NPROC
|
||||
except ImportError as err:
|
||||
self.skipTest(err) # RLIMIT_NPROC is specific to Linux and BSD
|
||||
limits = getrlimit(RLIMIT_NPROC)
|
||||
[_, hard] = limits
|
||||
setrlimit(RLIMIT_NPROC, (0, hard))
|
||||
self.addCleanup(setrlimit, RLIMIT_NPROC, limits)
|
||||
# Forking should raise EAGAIN, translated to BlockingIOError
|
||||
with self.assertRaises(BlockingIOError):
|
||||
subprocess.call([sys.executable, '-c', ''],
|
||||
preexec_fn=lambda: None)
|
||||
|
||||
def test_args_string(self):
|
||||
# args is a string
|
||||
fd, fname = tempfile.mkstemp()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue