diff --git a/README.md b/README.md index 9b9b2e1..4184044 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,12 @@ This module exposes the necessary API to create a worker which starts polling me We can install the library through github by writing the dependency in `requirements.txt` as: ``` -https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.1/aws_sqs_worker-0.0.1-py3-none-any.whl +https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.2/aws_sqs_worker-0.0.2-py3-none-any.whl ``` -Replace 0.0.1 with the desired version, on both places in the url! +Replace 0.0.2 with the desired version, on both places in the url! -If using pipenv, you can also run `pipenv install https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.1/aws_sqs_worker-0.0.1-py3-none-any.whl`. +If using pipenv, you can also run `pipenv install https://github.com/epidemicsound/aws-sqs-worker/releases/download/v0.0.2/aws_sqs_worker-0.0.2-py3-none-any.whl`. ## Steps necessary to create a worker for the process: diff --git a/setup.py b/setup.py index 510af92..3e3a381 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='aws-sqs-worker', - version='0.0.1', + version='0.0.2', description='AWS SQS Worker Module', license='MIT', long_description=long_description, diff --git a/worker/worker.py b/worker/worker.py index 99f6f60..d8aa292 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -9,10 +9,15 @@ class QueueServiceWorker: - def __init__(self, queue_name, handler, logger): + def __init__(self, queue_name, handler, logger, liveness_callback=None): self.queue_name = queue_name self.handler = handler self.logger = logger + self.liveness_callback = liveness_callback + + if settings.QUEUE_SERVICE_HOST is None: + raise Exception("aws-sqs-worker is missing a 'QUEUE_SERVICE_HOST' environment variable") + self.client = request_client.Client(settings.QUEUE_SERVICE_HOST) self.run = True @@ -75,6 +80,9 @@ def _work(self): else: raise Exception('Unhandled error {}', message_type) + if self.liveness_callback is not None: + self.liveness_callback() + self.logger.info('Work loop exited') def start(self):