ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> import-sig
import-sig
Re: [Import-sig] Imports with hooks not thread safe?
by Gordon McMillan other posts by this author
Jul 14 2002 1:58PM messages near this date
Re: [Import-sig] Imports with hooks not thread safe? | Re: [Import-sig] Imports with hooks not thread safe?
On 13 Jul 2002 at 20:55, Anthony Tuininga wrote:

>  Thanks. But wouldn't it make more sense to acquire the
>  lock around __any__ import, regardless of whether it
>  was hooked or not? 

You can't. Hooks typically *replace*
builtin.__import__. Imports from Python code
(where import has been hooked) don't necessarily touch
anything in the builtin Python import machinery.

[...]

>  I agree that the exposing of the import lock would
>  also solve the problem but that would mean that all
>  the import hooks would have to do this in order to
>  be thread safe. 

Correct. Writing a good import hook isn't easy.
Most import hooks are specializations or extensions
of behavior in some little area, so can get away with
it.

>  Or could it be placed in the core
>  imputils.py in the base class? Comments? 

iu is a replacement for imputils. imputils has a
number of flaws - no import lock; it does not
put None in sys.modules when the "is this a
relative import?" test fails. Can't recall what else,
but that's why I wrote iu.

-- Gordon
http://www.mcmillan-inc.com/



_______________________________________________
Import-sig mailing list
Import-sig@[...].org
http://mail.python.org/mailman/listinfo/import-sig
Thread:
Anthony Tuininga
Gordon McMillan
Anthony & Janet Tuininga
Gordon McMillan
Anthony Tuininga

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved