This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Overview

zamqp is aimed to broadcast messages and trigger events between python instances via AMQP.

It is based on amqplib and provides consumer and producer implementations as well as a mechanism to trigger zope events remotely.

Helper Classes

Create properties for AMQP connection.

>>> from zamqp import AMQPProps
>>> props = AMQPProps(host='localhost',
...                   user='guest',
...                   password='guest',
...                   ssl=False,
...                   exchange='zamqp.broadcast.fanout',
...                   type='fanout',
...                   realm='/data')

Create AMQP connection manually.

>>> from zamqp import AMQPConnection
>>> connection = AMQPConnection('zamqp_queue', props)

Access connection channel.

>>> connection.channel

Consumer and producer

Create consumer callback.

>>> def callback(message):
...     pass # do anything with received message here

Create and start consumer thread.

>>> from zamqp import AMQPConsumer
>>> from zamqp import AMQPThread
>>> consumer = AMQPConsumer('zamqp_queue', props, callback)
>>> thread = AMQPThread(consumer)
>>> thread.start()

Create producer and send a messages. Every python object which is serializable can be used as a message.

>>> from zamqp import AMQPProducer
>>> producer = AMQPProducer('zamqp_queue', props)
>>> message = 'foo'
>>> producer(message)

Trigger events

Create an event which should be triggered in the remote instance.

>>> class MyEvent(object):
...     def __init__(self, name):
...         self.name = name

Create a listener for MyEvent. This gets called when AMQP events are received.

>>> def my_listener(event):
...     if not isinstance(event, MyEvent):
...         return
...     # do something

>>> import zope.event
>>> zope.event.subscribers.append(my_listener)

The default AMQPEventCallback just calls zope.event.notify with the received payload, which is the serialized event, in this case an instance of MyEvent.

Start our AMQP consumer for events.

>>> exchange = 'zamqp.events.fanout'
>>> queue = 'zamqp_events'
>>> from zamqp import AMQPEventCallback
>>> props = AMQPProps(exchange=exchange)
>>> callback = AMQPEventCallback()
>>> consumer = AMQPConsumer(queue, props, callback)
>>> thread = AMQPThread(consumer)
>>> thread.start()

Trigger MyEvent to AMQP channel. The previously started event consumer now receives this event and triggers it locally in it’s own interpreter.

>>> from zamqp import AMQPEvent
>>> event = AMQPEvent(queue, props, MyEvent('myevent'))
>>> zope.event.notify(event)

Credits

-Robert Niederreiter <rnix@squarewave.at>

Changes

1.0b1

  • make it work [rnix]
Release History

Release History

1.0b1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
zamqp-1.0b1.tar.gz (4.7 kB) Copy SHA256 Checksum SHA256 Source Jun 14, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting