Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add idle runner #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sqs_listener/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@version: 0.2.3
@license: Apache
"""
from typing import Callable

# ================
# start imports
Expand Down Expand Up @@ -61,6 +62,7 @@ def __init__(self, queue, **kwargs):
self._endpoint_name = kwargs.get('endpoint_name', None)
self._wait_time = kwargs.get('wait_time', 0)
self._max_number_of_messages = kwargs.get('max_number_of_messages', 1)
self._run_while_idle = kwargs.get('run_while_idle', None)

# must come last
if boto3_session:
Expand Down Expand Up @@ -90,7 +92,7 @@ def _initialize_client(self):
errorQueueExists = True


# create queue if necessary.
# create queue if necessary.
# creation is idempotent, no harm in calling on a queue if it already exists.
if self._queue_url is None:
if not mainQueueExists:
Expand Down Expand Up @@ -195,6 +197,8 @@ def _start_listening(self):
)

else:
if isinstance(self._run_while_idle, Callable):
self._run_while_idle()
time.sleep(self._poll_interval)

def listen(self):
Expand Down