On Tue, Feb 09, 2010 at 07:19:45AM -0800, Damian wrote:
> app globals is not thread safe - if you write to it concurrently you
> will be in trouble.  I keep a lot of stuff in app globals that is set
> on startup and never changed.
> 
> If you need a cache use something like memcached - that works very
> well, and is easy to use.  I can recommend doing this through beaker
> as it has nice features such as dog-pile-effect prevention for when
> your cache expires.  If you cannot use memcached you can use other
> backends interchangably with beaker.

My objects aren't picklable or hashable - they have live TCP sessions.
This means they can't be stored in beaker or memcached.  I have to
have sockets hang around in some globally accessible memory.

Not being threadsafe isn't the end of the world for me.  I've just
hacked up a basic per-entry locking dictionary for my objects and it
seems to behave nicely in app_globals.

I'm concerned about bugs throwing exceptions in critical sections.  In
that case, I'll probably leak the mutex hold, which means subsequent
actions will fail.  Guess I need to fix all the bugs :)

-- 
Ross Vandegrift
r...@kallisti.us

"If the fight gets hot, the songs get hotter.  If the going gets tough,
the songs get tougher."
        --Woody Guthrie

Attachment: signature.asc
Description: Digital signature

Reply via email to