Skip to main content

Pools for pikas.

Project description

https://travis-ci.org/bninja/pika-pool.png https://coveralls.io/repos/bninja/pika-pool/badge.png?branch=master

Pika connection pooling inspired by:

Typically you’ll go with local shovel(s), krazy kombu, etc. but this might work too.

Get it:

$ pip install pika-pool

and use it:

import json

import pika
import pika_pool

params = pika.URLParameters(
   'amqp://guest:guest@localhost:5672/?'
   'socket_timeout=10&'
   'connection_attempts=2'
 )

 pool = pika_pool.QueuedPool(
     create=lambda: pika.BlockingConnection(parameters=params),
     max_size=10,
     max_overflow=10,
     timeout=10,
     recycle=3600,
     stale=45,
 )

 with pool.acquire() as cxn:
     cxn.channel.basic_publish(
         body=json.dumps({
             'type': 'banana',
             'description': 'they are yellow'
         }),
         exchange='',
         routing_key='fruits',
         properties=pika.BasicProperties(
             content_type='application/json',
             content_encoding='utf-8',
             delivery_mode=2,
         )
     )

Project details


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