Skip to main content

A python remote communications library

Project description


# kiwipy

| master | [![Build Status](https://travis-ci.org/muhrin/kiwipy.svg?branch=master)](https://travis-ci.org/muhrin/kiwipy)|
|--|--|
| dev |[![Build Status](https://travis-ci.org/muhrin/kiwipy.svg?branch=develop)](https://travis-ci.org/muhrin/kiwipy)|

kiwipy is a library that makes remote messaging using RabbitMQ (and any other protocol for which a backend is written) EASY. I don't know about you but I find RabbitMQ HARD. It's all too easy to make a configuration mistake which is then difficult to debug. With kiwipy, there's none of this, just messaging, made simple, with all the nice properties and guarantees of AMQP.

Here's what you get:
* RPC
* Broadcast (with filters)
* Task queue messages

Let's dive in, with some examples taken from the [rmq tutorial](https://www.rabbitmq.com/getstarted.html).

## RPC

The client:
```python
from kiwipy.rmq import *

communicator = RmqCommunicator(RmqConnector('amqp://localhost'))

# Send an RPC message
print(" [x] Requesting fib(30)")
response = communicator.rpc_send_and_wait('fib', 30)
print(" [.] Got %r" % response)
```
[(rmq_rpc_client.py source)](https://raw.githubusercontent.com/muhrin/kiwipy/develop/examples/rmq_rpc_client.py)


The server:
```python
from kiwipy.rmq import *

def fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fib(n - 1) + fib(n - 2)

communicator = RmqCommunicator(RmqConnector('amqp://localhost'))

# Register an RPC subscriber with the name square
communicator.add_rpc_subscriber(fib, 'fib')
communicator.await()
```
[(rmq_rpc_server.py source)](https://raw.githubusercontent.com/muhrin/kiwipy/develop/examples/rmq_rpc_server.py)


## Worker

Create a new task:
```python
from kiwipy.rmq import *
import sys

message = ' '.join(sys.argv[1:]) or "Hello World!"

communicator = RmqCommunicator(RmqConnector('amqp://localhost'))
communicator.task_send(message)
communicator.close()
```
[(rmq_new_task.py source)](https://raw.githubusercontent.com/muhrin/kiwipy/develop/examples/rmq_new_task.py)


And the worker:
```python
from kiwipy.rmq import *
import time

communicator = RmqCommunicator(RmqConnector('amqp://localhost'))

print(' [*] Waiting for messages. To exit press CTRL+C')


def callback(task):
print(" [x] Received %r" % task)
time.sleep(task.count(b'.'))
print(" [x] Done")


communicator.add_task_subscriber(callback)
communicator.await()
```
[(rmq_worker.py source)](https://raw.githubusercontent.com/muhrin/kiwipy/develop/examples/rmq_worker.py)


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiwipy-0.2.0.dev3.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

kiwipy-0.2.0.dev3-py2.py3-none-any.whl (21.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file kiwipy-0.2.0.dev3.tar.gz.

File metadata

  • Download URL: kiwipy-0.2.0.dev3.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kiwipy-0.2.0.dev3.tar.gz
Algorithm Hash digest
SHA256 ffbe47ca6b6390e940963913bf4a2eb55bef1545e9dd7d8b95a986a3e1cb442a
MD5 557fc60d245bdfe7b94149a0fa444eb7
BLAKE2b-256 4eb5bcc39589e52f46ab1463e586bd5c52e508dc6f0f52f3f672e088fc4e15d1

See more details on using hashes here.

Provenance

File details

Details for the file kiwipy-0.2.0.dev3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for kiwipy-0.2.0.dev3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8dee39052559e86e6eae5ec77b149e29466bde80892d320772fb450b64545686
MD5 f8479b4333cdf7af3694eb8911fb6102
BLAKE2b-256 7875798b85bd49b57648d87da25888e57713ea665cea627d4eaf8e480b396868

See more details on using hashes here.

Provenance

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