Package restkit :: Package ext :: Module gevent_pool :: Class GeventPool
[hide private]
[frames] | no frames]

Class GeventPool

source code

        object --+    
                 |    
pool.PoolInterface --+
                     |
                    GeventPool

Eventlet pool to manage connections. after a specific timeout the sockets are closes. Default timeout is 300s.

To use restkit with Gevent:

   >>> from restkit import *
   >>> from gevent import monkey; monkey.patch_socket()
   >>> from restkit.ext.gevent_pool import GeventPool
   >>> pool = GeventPool(max_connections=5)
   >>> r = request('http://friendpaste.com', pool_instance=pool)
Instance Methods [hide private]
 
__init__(self, max_connections=4, timeout=300)
Initialize EventletPool
source code
 
_remove_socket(self, socket) source code
 
get(self, address)
Get connection for (Host, Port) address :param address: tuple (Host, address)
source code
 
_monitor_socket(self, fn)
function used to monitor the socket
source code
 
monitor_socket(self, socket) source code
 
put(self, address, socket)
release socket in the pool
source code
 
clean(self, address)
close all sockets in the pool for this address
source code

Inherited from pool.PoolInterface: clear

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, max_connections=4, timeout=300)
(Constructor)

source code 

Initialize EventletPool

:param max_connexions: int, number max of connections in the pool. Default is 4 :param timeout: int, number max of second a connection is kept alive. Default is 300s.

Overrides: object.__init__

get(self, address)

source code 

Get connection for (Host, Port) address :param address: tuple (Host, address)

Overrides: pool.PoolInterface.get

put(self, address, socket)

source code 

release socket in the pool

:param address: tuple (Host, address) :param socket: a socket object

Overrides: pool.PoolInterface.put

clean(self, address)

source code 

close all sockets in the pool for this address

:param address: tuple (Host, address)