[Python-bugs-list] [ python-Bugs-580952 ] import lock should be exposed

noreply@sourceforge.net noreply@sourceforge.net
Sat, 13 Jul 2002 06:06:44 -0700


Bugs item #580952, was opened at 2002-07-13 13:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=580952&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Gordon B. McMillan (gmcm)
Assigned to: Nobody/Anonymous (nobody)
Summary: import lock should be exposed

Initial Comment:
See
http://mail.python.org/pipermail/import-sig/2002-July/000179.html

In brief, a good import hook needs to use an import
lock. But if it creates it's own import lock, you have the
possibility of a deadlock, since PyImport_ImportModuleEx
still uses the core lock. So one thread can end up
acquiring the hook's lock, then seeking the core lock.
While another holds the core lock, but  does an import
(routed through the hook) and seeks the hook's lock.

Seems to me exposing the core lock through
imp.acquire_lock() and imp.release_lock() would
allow a properly coded hook  to avoid this.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=580952&group_id=5470