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-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9161909ded75ff1bcf5aeb986f8e5832d5262fcd18964a812cce48d1013337fa |
|
MD5 | 48110b8ec3d266ac102a21a80a86081a |
|
BLAKE2b-256 | 78aba257e7f6312f3418cd8b3df2e64365d71a1b0dd38e016d70a60f519aedc9 |
Close
Hashes for rabbitmq_subprocess_client-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18ab91b6e4168ff4fa25ad18bac78d9d78a13a484953ffb2d6cdcb00c3e08ab8 |
|
MD5 | 80c05893a4c3a0a98d5cdc8f0f4075ee |
|
BLAKE2b-256 | f8c933434da38694cf59277edbcbf466ff164226c5f8db7e4c9ffa09f35a4409 |