[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.213,2.214

Tim Peters tim_one@users.sourceforge.net
Fri, 07 Dec 2001 12:35:46 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv10461/python/Modules

Modified Files:
	posixmodule.c 
Log Message:
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.


Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.213
retrieving revision 2.214
diff -C2 -d -r2.213 -r2.214
*** posixmodule.c	2001/12/03 20:41:00	2.213
--- posixmodule.c	2001/12/07 20:35:43	2.214
***************
*** 1669,1673 ****
  static char posix_spawnv__doc__[] =
  "spawnv(mode, path, args)\n\
! Execute an executable path with arguments, replacing current process.\n\
  \n\
  	mode: mode of process creation\n\
--- 1669,1673 ----
  static char posix_spawnv__doc__[] =
  "spawnv(mode, path, args)\n\
! Execute the program 'path' in a new process.\n\
  \n\
  	mode: mode of process creation\n\
***************
*** 1718,1723 ****
  	if (mode == _OLD_P_OVERLAY)
  		mode = _P_OVERLAY;
  	spawnval = _spawnv(mode, path, argvlist);
! 
  	PyMem_DEL(argvlist);
  
--- 1718,1726 ----
  	if (mode == _OLD_P_OVERLAY)
  		mode = _P_OVERLAY;
+ 	
+ 	Py_BEGIN_ALLOW_THREADS
  	spawnval = _spawnv(mode, path, argvlist);
! 	Py_END_ALLOW_THREADS
! 	
  	PyMem_DEL(argvlist);
  
***************
*** 1735,1739 ****
  static char posix_spawnve__doc__[] =
  "spawnve(mode, path, args, env)\n\
! Execute a path with arguments and environment, replacing current process.\n\
  \n\
  	mode: mode of process creation\n\
--- 1738,1742 ----
  static char posix_spawnve__doc__[] =
  "spawnve(mode, path, args, env)\n\
! Execute the program 'path' in a new process.\n\
  \n\
  	mode: mode of process creation\n\
***************
*** 1831,1835 ****
--- 1834,1842 ----
  	if (mode == _OLD_P_OVERLAY)
  		mode = _P_OVERLAY;
+ 
+ 	Py_BEGIN_ALLOW_THREADS
  	spawnval = _spawnve(mode, path, argvlist, envlist);
+ 	Py_END_ALLOW_THREADS
+ 
  	if (spawnval == -1)
  		(void) posix_error();