Skip to content

Commit 76762dc

Browse files
committed
Expose a non-thread-local base client class
This allows more advanced client pooling mechanisms to be used.
1 parent bad4122 commit 76762dc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

memcache.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ class _ConnectionDeadError(Exception):
106106
_SOCKET_TIMEOUT = 3 # number of seconds before sockets timeout.
107107

108108

109-
class Client(threading.local):
110-
"""Object representing a pool of memcache servers.
109+
class BasicClient(object):
110+
"""Object representing a pool of memcache servers. This is not thread-safe,
111+
and should either be wrapped in a thread-local variable or other
112+
synchronizing mechanism.
111113
112114
See L{memcache} for an overview.
113115
@@ -1500,6 +1502,14 @@ def __str__(self):
15001502
return "unix:%s%s" % (self.address, d)
15011503

15021504

1505+
class Client(BasicClient, threading.local):
1506+
"""
1507+
Thread-safe memcache client. See L{BasicClient} for more information on how
1508+
to use this class.
1509+
"""
1510+
pass
1511+
1512+
15031513
def _doctest():
15041514
import doctest
15051515
import memcache

0 commit comments

Comments
 (0)