Package wtf :: Package ext :: Module memcache :: Class MemcacheConnectionPool
[hide private]
[frames] | no frames]

Class MemcacheConnectionPool

source code

   object --+    
            |    
util.BasePool --+
                |
               MemcacheConnectionPool

Memcache connection pool
Instance Methods [hide private]
 
__init__(self, maxconn, maxcached, spec, weight=None, timeout=None)
Initialization
source code
PooledInterface
_create(self)
Create a pooled object
source code
 
put_conn(self, conn)
Put back connection, but only if not dead
source code
 
mark_dead(self, grace_time, retry_time, pools)
Mark this pool dead
source code
 
mark_alive(self)
Mark this pool alive
source code

Inherited from util.BasePool: __del__, clear, del_obj, get_obj, put_obj, shutdown

Inherited from util.BasePool (private): _fork_protect

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
bool _FORK_PROTECT = True
Clear the pool, when the PID changes?

Inherited from util.BasePool (private): _LOCK

Instance Variables [hide private]
tuple _dead = False
dead state and recovery information during dead time.
threading.RLock _deadlock
Lock for dead state access
int _stamp = None
Timestamp when the next event should happen.
int _state = None
The current state of the pool during dead time (STATE_GRACE or STATE_RETRY)
tuple backup = ()
The weighted backup pools used in retry state
callable del_conn
Connection deleter
callable get_conn
Connection getter
tuple spec
Connection spec
int timediff = 0
Time difference between client and server in seconds.
float timeout
Communication timeout
int weight
Relative pool weight
Properties [hide private]
  dead
(bool) The current dead state
  state
(tuple) The pool's state.

Inherited from object: __class__

Method Details [hide private]

__init__(self, maxconn, maxcached, spec, weight=None, timeout=None)
(Constructor)

source code 
Initialization
Parameters:
  • maxconn (int) - Hard maximum of connections to hand out
  • maxcached (int) - Maximum number of connections to cache
  • spec (tuple) - Memcache location spec (('host', port))
  • weight (int) - Relative pool weight (defaults to 1)
  • timeout (float) - Memcache timeout (defaults to None - no timeout)
Overrides: object.__init__

_create(self)

source code 

Create a pooled object

This method must be implemented by subclasses.

Returns: PooledInterface
A new object
Overrides: util.BasePool._create

See Also: BasePool._create

put_conn(self, conn)

source code 
Put back connection, but only if not dead
Parameters:
  • conn (MemcacheConnection) - The connection to put back. If the pool is marked dead, the connection is just destroyed

mark_dead(self, grace_time, retry_time, pools)

source code 
Mark this pool dead
Parameters:
  • grace_time (int) - Grace time
  • retry_time (int) - Retry time
  • pools (tuple) - List of available pools

mark_alive(self)

source code 

Mark this pool alive

The method unconditionally removes the backup pool list and the dead status.


Instance Variable Details [hide private]

_dead

dead state and recovery information during dead time. If the pool is alive the value is None. If it's dead it's a tuple containing the retry time and the pool list. ((int, tuple))
Type:
tuple
Value:
False

_stamp

Timestamp when the next event should happen. That is either the switch from grace state to retry state or the next retry.
Type:
int
Value:
None

timediff

Time difference between client and server in seconds. The value is determined after each real connect (c_time - s_time)
Type:
int
Value:
0

Property Details [hide private]

dead

(bool) The current dead state
Get Method:
unreachable.dead(self) - Determine dead state of the pool

state

(tuple) The pool's state.

The first item is the dead state (STATE_GRACE or STATE_RETRY) or None if the pool is not dead. The second item is only useful in retry state. Then it's a boolean answering the question whether we hit a retry point or not.

Get Method:
unreachable.state(self) - Determine the pool's state