[Python-bugs-list] [ python-Bugs-580952 ] import lock should be exposed
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 14 Jul 2002 14:34:02 -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: Guido van Rossum (gvanrossum)
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.
----------------------------------------------------------------------
>Comment By: Gordon B. McMillan (gmcm)
Date: 2002-07-14 21:34
Message:
Logged In: YES
user_id=4923
Yes, I would just like to expose the current lock_import and
unlock_import to C and Python.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-07-14 21:06
Message:
Logged In: YES
user_id=31435
I don't understand how imports work, at least not at this
level. I note that the current lock_import() and
unlock_import() arrange to implement a reentrant lock: in
the absence of you supplying a patch, are these the
functions you would like to see exposed? Given the games
being played here, it seems too dangerous to expose the
*underlying* lock's acquire and release methods directly.
Assigned to Guido for cogitation.
----------------------------------------------------------------------
Comment By: Gordon B. McMillan (gmcm)
Date: 2002-07-13 13:10
Message:
Logged In: YES
user_id=4923
Assigning to Tim for initial review.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=580952&group_id=5470