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
[Import-sig] Imports with hooks not thread safe?
by Anthony Tuininga other posts by this author
Jul 12 2002 9:00PM messages near this date
Re: [Import-sig] imputil with only .pyc files | Re: [Import-sig] Imports with hooks not thread safe?
I just joined this list so my apologies if this has been discussed
before. The list (from the archives) seems close to dead with a
suggestion to kill it permanently.... :-)

I noticed that in PyImport_ImportModuleEx, that a lock is held until the
import is completed or an exception is raised. The only problem is that
the higher level interface PyImport_Import does __NOT__ hold the lock
and this is the method that is used for hooks. The builtin function
__import__ calls PyImport_ImportModuleEx but if that function is
replaced with a call to a hook, no locking takes place which makes the
import mechanism not thread safe.

My question is: would there be a problem with holding the lock during
PyImport_Import? If there is, would there be a problem with exposing a
method that would do the import lock? The only thing that is currently
available is imp.lock_held() but that simply states whether or not the
import lock is held and nothing that I could see provides any mechanism
for acquiring the import lock.

I am using Installer (from Gordon McMillan) and it is using its own
locking mechanism which seems to break inside PythonCOM (from Mark
Hammond) if a large enough quantity of threads are executing. All of my
imports are done within the import of the main module which is done
using the normal method but I would like to solve this problem in a more
permanent way as otherwise I will have to fork Installer for our own
internal use. Blech.

-- 
Anthony Tuininga
anthony@[...].com
 
Computronix
Distinctive Software. Real People.
Suite 200, 10216 - 124 Street NW
Edmonton, AB, Canada  T5N 4A3
Phone:	(780) 454-3700
Fax:	(780) 454-3838
http://www.computronix.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