mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
SF patch #489173: Make os.spawnv not block the interpreter, from
Anthony Roach. Release the global interpreter lock around platform spawn calls. Bugfix candidate? Hard to say; I favor "yes, bugfix". These clearly *should* have been releasing the GIL all along, if for no other reason than compatibility with the similar os.system(). But it's possible some program out there is (a) multithreaded, (b) calling a spawn function with P_WAIT, and (c) relying on the spawn call to block all their threads until the spawned program completes. I think it's very unlikely anyone is doing that on purpose, but someone may be doing so by accident.
This commit is contained in:
parent
2f09812efa
commit
25059d30c3
3 changed files with 18 additions and 3 deletions
|
|
@ -353,6 +353,7 @@ Jan Pieter Riegel
|
||||||
Armin Rigo
|
Armin Rigo
|
||||||
Nicholas Riley
|
Nicholas Riley
|
||||||
Jean-Claude Rimbault
|
Jean-Claude Rimbault
|
||||||
|
Anthony Roach
|
||||||
Andy Robinson
|
Andy Robinson
|
||||||
Jim Robinson
|
Jim Robinson
|
||||||
Kevin Rodgers
|
Kevin Rodgers
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,13 @@ Extension modules
|
||||||
|
|
||||||
Library
|
Library
|
||||||
|
|
||||||
|
- Functions in the os.spawn() family now release the global interpreter
|
||||||
|
lock around calling the platform spawn. They should always have done
|
||||||
|
this, but did not before 2.2c1. Multithreaded programs calling
|
||||||
|
an os.spawn function with P_WAIT will no longer block all Python threads
|
||||||
|
until the spawned program completes. It's possible that some programs
|
||||||
|
relies on blocking, although more likely by accident than by design.
|
||||||
|
|
||||||
- webbrowser defaults to netscape.exe on OS/2 now.
|
- webbrowser defaults to netscape.exe on OS/2 now.
|
||||||
|
|
||||||
- Tix.ResizeHandle exposes detach_widget, hide, and show.
|
- Tix.ResizeHandle exposes detach_widget, hide, and show.
|
||||||
|
|
|
||||||
|
|
@ -1668,7 +1668,7 @@ posix_execve(PyObject *self, PyObject *args)
|
||||||
#ifdef HAVE_SPAWNV
|
#ifdef HAVE_SPAWNV
|
||||||
static char posix_spawnv__doc__[] =
|
static char posix_spawnv__doc__[] =
|
||||||
"spawnv(mode, path, args)\n\
|
"spawnv(mode, path, args)\n\
|
||||||
Execute an executable path with arguments, replacing current process.\n\
|
Execute the program 'path' in a new process.\n\
|
||||||
\n\
|
\n\
|
||||||
mode: mode of process creation\n\
|
mode: mode of process creation\n\
|
||||||
path: path of executable file\n\
|
path: path of executable file\n\
|
||||||
|
|
@ -1717,7 +1717,10 @@ posix_spawnv(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (mode == _OLD_P_OVERLAY)
|
if (mode == _OLD_P_OVERLAY)
|
||||||
mode = _P_OVERLAY;
|
mode = _P_OVERLAY;
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
spawnval = _spawnv(mode, path, argvlist);
|
spawnval = _spawnv(mode, path, argvlist);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
PyMem_DEL(argvlist);
|
PyMem_DEL(argvlist);
|
||||||
|
|
||||||
|
|
@ -1734,7 +1737,7 @@ posix_spawnv(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
static char posix_spawnve__doc__[] =
|
static char posix_spawnve__doc__[] =
|
||||||
"spawnve(mode, path, args, env)\n\
|
"spawnve(mode, path, args, env)\n\
|
||||||
Execute a path with arguments and environment, replacing current process.\n\
|
Execute the program 'path' in a new process.\n\
|
||||||
\n\
|
\n\
|
||||||
mode: mode of process creation\n\
|
mode: mode of process creation\n\
|
||||||
path: path of executable file\n\
|
path: path of executable file\n\
|
||||||
|
|
@ -1830,7 +1833,11 @@ posix_spawnve(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (mode == _OLD_P_OVERLAY)
|
if (mode == _OLD_P_OVERLAY)
|
||||||
mode = _P_OVERLAY;
|
mode = _P_OVERLAY;
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
spawnval = _spawnve(mode, path, argvlist, envlist);
|
spawnval = _spawnve(mode, path, argvlist, envlist);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
if (spawnval == -1)
|
if (spawnval == -1)
|
||||||
(void) posix_error();
|
(void) posix_error();
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue