5b1d3b6503
fix cxn str to work w/ pika.BlockingConnection |
||
---|---|---|
.gitignore | ||
.travis.yml | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
pika_pool.py | ||
setup.py | ||
test.py |
README.rst
pika-pool
Pika connection pooling inspired by:
Typically you'll go with local shovels, krazee-eyez kombu, etc. but this works too.
usage
Get it:
pip install pika-pool
and use it:
import json
import pika
import pika_pool
= pika.URLParameters(
params 'amqp://guest:guest@localhost:5672/?'
'socket_timeout=10&'
'connection_attempts=2'
)
= pika_pool.QueuedPool(
pool =lambda: pika.BlockingConnection(parameters=params),
create=10,
max_size=10,
max_overflow=10,
timeout=3600,
recycle=45,
stale
)
with pool.acquire() as cxn:
cxn.channel.basic_publish(=json.dumps({
body'type': 'banana',
'description': 'they are yellow'
}),='',
exchange='fruits',
routing_key=pika.BasicProperties(
properties='application/json',
content_type='utf-8',
content_encoding=2,
delivery_mode
) )
release
Tests pass:
py.test test.py --cov=pika_pool --cov-report term-missing
so update __version__
in:
__init__.py
then commit and tag it:
git commit -am "release v{version}"
git tag -a v{version} -m "release v{version}"
git push --tags