[Zope-dev] thread safety in external methods

Jim Fulton jim@digicool.com
Fri, 03 Sep 1999 09:05:56 -0400


Robin Becker wrote:
> 
> My original reply to Michel shows that doing as you suggest in the
> external method isn't sufficient. If two calls hit the method together
> then two locks may be created simultaneously and then the lock doesn't
> work.

Oops. Good point.

> It seems that each invocation of an external method gets a private
> global space.

Right. External method files are *not* modules.  They should not depend on 
usual module semantics.

> I have to move the lock into an imported file to get a lock to work. And
> in fact you're right as soon as I have the imported file I can keep
> __ZGA there and not in __main__.

The right answer in a case like this is to use a product, 
not an external method.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.