Skip to content

Commit

Permalink
Merge pull request #2859 from fedspendingtransparency/mod/dev-6468-up…
Browse files Browse the repository at this point in the history
…date-sqs-to-use-correct-endpoint-url

[DEV-6468] Update boto3 endpoint format for SQS
  • Loading branch information
sethstoudenmier authored Nov 25, 2020
2 parents bda4edb + cc2fc97 commit 1e76b85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion usaspending_api/common/sqs/sqs_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,6 @@ def get_sqs_queue(region_name=settings.USASPENDING_AWS_REGION, queue_name=settin
return _FakeFileBackedSQSQueue.instance()
else:
# stuff that's in get_queue
sqs = boto3.resource("sqs", region_name)
sqs = boto3.resource("sqs", endpoint_url=f"https://sqs.{region_name}.amazonaws.com", region_name=region_name)
queue = sqs.get_queue_by_name(QueueName=queue_name)
return queue
5 changes: 3 additions & 2 deletions usaspending_api/common/tests/unit/test_sqs_work_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,10 @@ def work_one_or_two(message):
def test_faulty_queue_connection_raises_correct_exception(self):
"""When a queue cannot be connected to, it raises the appropriate exception"""
try:
region_name = "us-gov-west-1"
# note: connection max retries config not in botocore v1.5.x
client_config = Config(region_name="us-gov-west-1", connect_timeout=1, read_timeout=1)
sqs = boto3.resource("sqs", config=client_config)
client_config = Config(region_name=region_name, connect_timeout=1, read_timeout=1)
sqs = boto3.resource("sqs", config=client_config, endpoint_url=f"https://sqs.{region_name}.amazonaws.com")
queue = sqs.Queue("75f4f422-3866-4e4f-9dc9-5364e3de3eaf")
dispatcher = SQSWorkDispatcher(
queue, worker_process_name="Test Worker Process", long_poll_seconds=1, monitor_sleep_time=1
Expand Down

0 comments on commit 1e76b85

Please sign in to comment.