Richard Oudkerk added the comment:

Python 3.2 has extra code in _PyImport_ReInitLock() which means that when a 
fork happens as a side effect of an import, the main thread of the forked 
process owns the import lock.  Therefore other threads in the forked process 
cannot import anything.

_PyImport_ReInitLock(void)
{
    if (import_lock != NULL)
        import_lock = PyThread_allocate_lock();
    if (import_lock_level > 1) {
        /* Forked as a side effect of import */
        long me = PyThread_get_thread_ident();
        PyThread_acquire_lock(import_lock, 0);
        /* XXX: can the previous line fail? */
        import_lock_thread = me;
        import_lock_level--;
    } else {
        import_lock_thread = -1;
        import_lock_level = 0;
    }
}

I think the reason this code is not triggered in Python 3.3 is the introduction 
of per-module import locks.

----------
type: behavior -> crash

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15914>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to