Le vendredi 7 octobre 2011 15:02:44, Vincent Pelletier a écrit :
> Le vendredi 7 octobre 2011 14:16:42, Andreas Gabriel a écrit :
> > However, is your implementation thread safe? Maybe I am blind ;). That
> > was the reason  I used lovely.memcached as memcached connector. Each
> > thread has its own connection and namespace to store keys. Therefore,
> > the locks from one or more zeo-clients with multiple threads ẃere
> > distinguishable.
> You're not blind :) .

I've read python-memcached module: it is internally thread-safe as it uses one 
network connection per thread sharing the same instance.

I haven't implemented any namespace separation per thread, but I'm not sure of 
the point: if I share a single threading.Lock instance between threads, a 
single one can successfully acquire it - and this is the point of a lock. 
Adding "distributed" should work the same way, but not only across different 
threads but also different processes and machines. So locks for the same 
resource (identified by their "key" as you named it in your code - and I kept 
the naming) should be able to access the same memcache entry (ie, same 

Did I miss something ?

If not, I believe my code is thread-safe.

Vincent Pelletier
ERP5 - open source ERP/CRM for flexible enterprises
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to