diff --git a/memcache.py b/memcache.py index 05b6657..85273a5 100644 --- a/memcache.py +++ b/memcache.py @@ -106,8 +106,10 @@ class _ConnectionDeadError(Exception): _SOCKET_TIMEOUT = 3 # number of seconds before sockets timeout. -class Client(threading.local): - """Object representing a pool of memcache servers. +class BasicClient(object): + """Object representing a pool of memcache servers. This is not thread-safe, + and should either be wrapped in a thread-local variable or other + synchronizing mechanism. See L{memcache} for an overview. @@ -207,7 +209,7 @@ def __init__(self, servers, debug=0, pickleProtocol=0, to ensure it is the correct length and composed of the right characters. """ - super(Client, self).__init__() + super(BasicClient, self).__init__() self.debug = debug self.dead_retry = dead_retry self.socket_timeout = socket_timeout @@ -1500,6 +1502,14 @@ def __str__(self): return "unix:%s%s" % (self.address, d) +class Client(threading.local, BasicClient): + """ + Thread-safe memcache client. See L{BasicClient} for more information on how + to use this class. + """ + pass + + def _doctest(): import doctest import memcache