[Zope] thread safety

Oleg Broytmann Oleg Broytmann <phd@phd.fep.ru>
Wed, 16 May 2001 18:56:53 +0400 (MSD)


On Wed, 16 May 2001, Jerome Alet wrote:
> In the ZShell external method I've written, I've got some code which does
> the shell globbing for wildcards using the glob.glob module after having
> redirected some methods from the os module to my own, e.g. :
>
> --- CUT ---
> 	oldlistdir = os.listdir
> 	os.listdir = mylistdir
> 	...
> 	glob.glob(...)
> 	...
> 	os.listdir = oldlistdir
> 	...
> --- CUT ---
>
> So my question is: is this code thread safe, wrt to other Zope threads

   Certainly no.

> accessing the os module methods while they are redirected to mine ? I
> don't want other Zope threads to access my own methods, just the current
> one.
>
> If it is not thread safe, then how can I do it another way ?

   Write your own glob(). Or use locks.

Oleg.
----
     Oleg Broytmann     http://www.zope.org/Members/phd/     phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.