https://github.com/zhouyl/connectionpool
Thread-safe connection pool
https://github.com/zhouyl/connectionpool
connection-pool pool python python2 python3 thread-safety
Last synced: 4 months ago
JSON representation
Thread-safe connection pool
- Host: GitHub
- URL: https://github.com/zhouyl/connectionpool
- Owner: zhouyl
- License: mit
- Created: 2018-06-08T01:21:01.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-17T02:54:40.000Z (over 4 years ago)
- Last Synced: 2024-06-20T22:42:15.202Z (12 months ago)
- Topics: connection-pool, pool, python, python2, python3, thread-safety
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 14
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
ConnectionPool
##############Thread-safe connection pool for python
Install
=======.. code-block:: bash
$ pip install connection_pool
Examples
========Create a pool
---------------.. code-block:: python
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.