rabbitmq-subprocess-client is a RabbitMQ client (based on `pika`) spawning tasks as subprocess, allowing handling segfault gracefully.
Project description
RabbitMQ-subprocess-client
RabbitMQ-subprocess-client is a RabbitMq client (based on pika
) spawning tasks as subprocess, allowing handling segfault gracefully.
Install
pip install rabbitmq-subprocess-client
usage
import os
from concurrent.futures import TimeoutError
import traceback
from rabbitmq_subprocess_client import Runner, Consumer
class MyConsumer(Consumer):
def consume_main(self, basic_deliver, msg):
print(f'pre-processing message: {msg} in process: {os.getpid()}')
try:
args = []
kwargs = {}
self.exec(msg, *args, **kwargs) # This will run the consume_subprocess method in a subprocess
self.acknowledge_message(basic_deliver.delivery_tag)
except TimeoutError:
self.nacknowledge_message(basic_deliver.delivery_tag)
except BaseException:
exc_msg = traceback.format_exc()
print(exc_msg)
self.nacknowledge_message(basic_deliver.delivery_tag)
@staticmethod
def consume_subprocess(msg, *args, **kwargs):
print(f'processing message: {msg} in process: {os.getpid()}')
worker = Runner(
'my_queue',
MyConsumer,
host="127.0.0.1",
port="5672",
user="guest",
password="guest",
timeout=None,
)
worker.run()
develop
poetry shell
poetry install
pytest
pre-commit install
Publish new version
poetry publish --build --username= --password=
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
Built Distribution
Close
Hashes for rabbitmq-subprocess-client-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b94d4fdf907e6e2bf52f7494c98afb2132ee0955ff26f4be3ca92ea7cb794d71 |
|
MD5 | 90ceed1e791caed19843870d31fe6853 |
|
BLAKE2b-256 | 77be10b6dd034168f82c628bbe5dca09eb65dd36e30917f3c74777ea65ab57a6 |
Close
Hashes for rabbitmq_subprocess_client-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15fc0f159e47ca513d0d7e9aa0689344ffc90329cb5e4ff76ab2d6549c2cee9b |
|
MD5 | cf6ad213149fb06e574e09b7a7f6004e |
|
BLAKE2b-256 | e60c4123f8b699da06852698fd5f51c43faf73a00b88c3fbbcb4299850ae04d1 |