quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Gardner <jgard...@smoothcorp.com>
Subject Re: [mod_python] Using shared memory to do global persistence
Date Fri, 27 Jun 2003 13:34:16 GMT
On Thursday 26 June 2003 21:10, Jeff Stearns wrote:
> This code isn't thread-safe. It's entirely possible that
> 	cache['foo'] = 'bar'
> will raise an exception.
>

I'm curious. Wouldn't this just block until it could get a write lock on the 
dict (on at least the 'foo' entry in the dict)? Why would an exception ever 
be raised?

The only thing I see wrong with the code example is that some other process 
could quickly slip in a new value for 'foo' in between the checking of 'foo' 
and the setting of 'foo'. This isn't completely terrible.

-- 
Jonathan M. Gardner
Smooth Corporation - Perl Programmer
jgardner@smoothcorp.com - (425) 460-4780
Live Free, Use Linux!

Mime
View raw message