[Zope] thread safety

Toby Dickenson tdickenson@geminidataloggers.com
Wed, 16 May 2001 16:01:02 +0100

On Wed, 16 May 2001 16:44:37 +0200 (MET DST), Jerome Alet
<alet@unice.fr> wrote:

>So my question is: is this code thread safe, wrt to other Zope threads
>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

It is not thread safe

>If it is not thread safe, then how can I do it another way ?

What you _really_ want to do is create a duplicate of a module (glob)
but providing it with a replacement for a standard module (os).

The cheeky solution involves using the standard library module rexec.
It was designed for replacing modules in a security sandbox (for
example, replacing the standard 'open' function with one that limits
access to a specific directory) but it will do exactly what you want

The python documentation for this module is a little thin, but there
is deeper documentation on www.python.org.

Toby Dickenson