Skip to main content

thread safe connection pool

Project description

Thread-safe connection pool for python

Install

$ pip install connection_pool

Examples

Create a pool

import memcache
from connection_pool import ConnectionPool

# via create function
def create_memcache_client():
    return memcache.Client(['127.0.0.1:11211'])

pool = ConnectionPool(create=create_memcache_client,
                      max_size=10, max_usage=10000, idle=60, ttl=120)

# via lambda
pool = ConnectionPool(create=lambda: memcache.Client(['127.0.0.1:11211']),
                      max_size=10)

# via functools.partial
from functools import partial
pool = ConnectionPool(create=partial(memcache.Client, ['127.0.0.1:11211']),
                      max_size=10)

# using a connection
with pool.item() as memcache:
    memcache.set('foo', 'bar')

License

The MIT License (MIT). Please see License File for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

connection_pool-0.0.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page