Package restkit :: Package pool :: Module base
[hide private]
[frames] | no frames]

Source Code for Module restkit.pool.base

 1  # -*- coding: utf-8 - 
 2  # 
 3  # This file is part of restkit released under the MIT license.  
 4  # See the NOTICE for more information. 
 5   
 6   
 7   
8 -class BasePool(object):
9
10 - def __init__(self, keepalive=10, timeout=300):
11 """ abstract class from which all connection 12 pool should inherit. 13 """ 14 if type(timeout) != type(1): 15 raise ValueError("Pool timeout isn't an integer") 16 self.keepalive = keepalive 17 self.timeout = timeout 18 self.alive = True
19
20 - def get(self, netloc):
21 """ method used to return a connection from the pool""" 22 raise NotImplementedError
23
24 - def put(self, netloc, conn):
25 """ Put an item back into the pool, when done """ 26 raise NotImplementedError
27
28 - def clear_host(self, netloc):
29 """ method to clear all connections from host """ 30 raise NotImplementedError
31
32 - def clear(self):
33 """ method used to release all connections """ 34 raise NotImplementedError
35
36 - def close(self):
37 """ close the pool monitoring and clear all connections """ 38 self.alive = False 39 self.clear()
40