This is initialized lazily in _PyImport_FixupExtensionObject().
Modules are added there and looked up in _imp.find_extension(). */
PyObject *extensions;
+ /* The global import lock. */
+ struct {
+ PyThread_type_lock mutex;
+ unsigned long thread;
+ int level;
+ } lock;
+ struct {
+ int import_level;
+ _PyTime_t accumulated;
+ int header;
+ } find_and_load;
};
in different threads to return with a partially loaded module.
These calls are serialized by the global interpreter lock. */
-static PyThread_type_lock import_lock = NULL;
-static unsigned long import_lock_thread = PYTHREAD_INVALID_THREAD_ID;
-static int import_lock_level = 0;
+#define import_lock _PyRuntime.imports.lock.mutex
+#define import_lock_thread _PyRuntime.imports.lock.thread
+#define import_lock_level _PyRuntime.imports.lock.level
void
_PyImport_AcquireLock(void)
PyObject *mod = NULL;
PyInterpreterState *interp = tstate->interp;
int import_time = _PyInterpreterState_GetConfig(interp)->import_time;
- static int import_level;
- static _PyTime_t accumulated;
+#define import_level _PyRuntime.imports.find_and_load.import_level
+#define accumulated _PyRuntime.imports.find_and_load.accumulated
_PyTime_t t1 = 0, accumulated_copy = accumulated;
* _PyDict_GetItemIdWithError().
*/
if (import_time) {
- static int header = 1;
+#define header _PyRuntime.imports.find_and_load.header
if (header) {
fputs("import time: self [us] | cumulative | imported package\n",
stderr);
header = 0;
}
+#undef header
import_level++;
t1 = _PyTime_GetPerfCounter();
}
return mod;
+#undef import_level
+#undef accumulated
}
PyObject *
Python/fileutils.c - _Py_open_cloexec_works -
Python/fileutils.c - force_ascii -
Python/fileutils.c set_inheritable ioctl_works -
-Python/import.c - import_lock -
-Python/import.c import_find_and_load header -
#-----------------------
# unlikely to change after init (or main thread)
Python/ceval_gil.c make_pending_calls busy -
Python/ceval.c _PyEval_SetProfile reentrant -
Python/ceval.c _PyEval_SetTrace reentrant -
-Python/import.c - import_lock_level -
-Python/import.c - import_lock_thread -
-Python/import.c import_find_and_load accumulated -
-Python/import.c import_find_and_load import_level -
Python/modsupport.c - _Py_PackageContext -
Python/thread_pthread_stubs.h - py_tls_entries -
Python/pyfpe.c - PyFPE_counter -