This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author seberg
Recipients christian.heimes, jhgoebbert, seberg
Date 2022-03-21.23:04:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647903878.8.0.133933479009.issue47082@roundup.psfhosted.org>
In-reply-to
Content
Thanks, so there should already be a lock in place (sorry, I missed that).  But somehow we seem to get around it?

Do you know what may cause the locking logic to fail in this case?  Recursive imports in NumPy itself?  Or Cython using low-level C-API?

I.e. can you think of something to investigate that may help NumPy/Cython to make sure that locking is successful?


/* Cythons Import code (slightly cleaned up for Python 3 only): */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        if (!module) {
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
        }
    }
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}
History
Date User Action Args
2022-03-21 23:04:38sebergsetrecipients: + seberg, christian.heimes, jhgoebbert
2022-03-21 23:04:38sebergsetmessageid: <1647903878.8.0.133933479009.issue47082@roundup.psfhosted.org>
2022-03-21 23:04:38seberglinkissue47082 messages
2022-03-21 23:04:38sebergcreate