[Python-checkins] CVS: python/dist/src/Python import.c,2.185,2.186

Tim Peters tim_one@users.sourceforge.net
Wed, 29 Aug 2001 22:16:15 -0700


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

Modified Files:
	import.c 
Log Message:
Add a new function imp.lock_held(), and use it to skip test_threaded_import
when that test is doomed to deadlock.


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.185
retrieving revision 2.186
diff -C2 -d -r2.185 -r2.186
*** import.c	2001/08/13 23:05:44	2.185
--- import.c	2001/08/30 05:16:13	2.186
***************
*** 182,185 ****
--- 182,197 ----
  #endif
  
+ static PyObject *
+ imp_lock_held(PyObject *self, PyObject *args)
+ {
+ 	if (!PyArg_ParseTuple(args, ":lock_held"))
+ 		return NULL;
+ #ifdef WITH_THREAD
+ 	return PyInt_FromLong(import_lock_thread != -1);
+ #else
+ 	return PyInt_FromLong(0);
+ #endif
+ }
+ 
  /* Helper for sys */
  
***************
*** 2340,2343 ****
--- 2352,2361 ----
  ";
  
+ static char doc_lock_held[] = "\
+ lock_held() -> 0 or 1\n\
+ Return 1 if the import lock is currently held.\n\
+ On platforms without threads, return 0.\
+ ";
+ 
  static PyMethodDef imp_methods[] = {
  	{"find_module",		imp_find_module,	1, doc_find_module},
***************
*** 2346,2349 ****
--- 2364,2368 ----
  	{"load_module",		imp_load_module,	1, doc_load_module},
  	{"new_module",		imp_new_module,		1, doc_new_module},
+ 	{"lock_held",		imp_lock_held,		1, doc_lock_held},
  	/* The rest are obsolete */
  	{"get_frozen_object",	imp_get_frozen_object,	1},