Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

thread safe connection pool

Project description

Thread-safe connection pool for python

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

he 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.

Files for connection-pool, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size connection_pool-0.0.2-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size connection_pool-0.0.2.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page