Skip to content

Commit

Permalink
Merge pull request jegesh#38 from hjpotter92/patch-1
Browse files Browse the repository at this point in the history
Make the SqlLauncher more pythonic.
  • Loading branch information
jegesh authored Jul 5, 2020
2 parents d08b8df + 66a21a9 commit 295dfc2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions sqs_launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, queue=None, queue_url=None, create_queue=False, visibility_ti
to finish execution. See http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html
for more information
"""
if not queue and not queue_url:
if not any(queue, queue_url):
raise ValueError('Either `queue` or `queue_url` should be provided.')
if (not os.environ.get('AWS_ACCOUNT_ID', None) and
not (boto3.Session().get_credentials().method in ['iam-role', 'assume-role'])):
Expand Down Expand Up @@ -81,15 +81,10 @@ def launch_message(self, message, **kwargs):
:return: (dict) the message response from SQS
"""
sqs_logger.info("Sending message to queue " + self._queue_name)
if not kwargs:
return self._client.send_message(
QueueUrl=self._queue_url,
MessageBody=json.dumps(message)
)
return self._client.send_message(
QueueUrl=self._queue_url,
MessageBody=json.dumps(message),
**kwargs
**kwargs,
)

def _get_queue_name_from_url(self, url):
Expand Down

0 comments on commit 295dfc2

Please sign in to comment.