[Python-Dev] Deadlock by a second import in a thread

Facundo Batista facundobatista at gmail.com
Sat Oct 20 16:20:20 CEST 2007


2007/10/19, Christian Heimes <lists at cheimes.de>:

> I know a possible solution. You could write a patch that moves the
> imports in C code to the module init function and stores the modules in
> a global static variable.

I thought about this. It even will have the good side efect of not
shooting the whole "import" machinery to see that you already imported
it, every time you do an strptime.

One question: The program makes this:

    PyObject *strptime_module = PyImport_ImportModule("_strptime");
    ...
    Py_DECREF(strptime_module);

If I'd import it in the beggining of the file with the following...

    static PyObject *strptime_module = PyImport_ImportModule("_strptime");

... I'd never decref it, right?

Thank you!

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the Python-Dev mailing list