Skip to content

Commit

Permalink
Only try to delete if there are entries (#3885)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss authored and metroid-samus committed Oct 20, 2023
1 parent 2840585 commit 7fdb8d1
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/dispatch/plugins/dispatch_aws/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def consume(self, db_session, project):
QueueOwnerAWSAccountId=self.configuration.queue_owner,
)["QueueUrl"]

while True:
response = client.receive_message(
QueueUrl=queue_url,
MaxNumberOfMessages=self.configuration.batch_size,
VisibilityTimeout=40,
WaitTimeSeconds=20,
)
if response.get("Messages") and len(response.get("Messages")) > 0:
entries = []
for message in response["Messages"]:
try:
try:
while True:
response = client.receive_message(
QueueUrl=queue_url,
MaxNumberOfMessages=self.configuration.batch_size,
VisibilityTimeout=40,
WaitTimeSeconds=20,
)
if response.get("Messages") and len(response.get("Messages")) > 0:
entries = []
for message in response["Messages"]:
body = json.loads(message["Body"])
signal_data = json.loads(body["Message"])

Expand All @@ -72,7 +72,7 @@ def consume(self, db_session, project):
entries.append(
{"Id": message["MessageId"], "ReceiptHandle": message["ReceiptHandle"]}
)
except Exception as e:
log.exception(e)

client.delete_message_batch(QueueUrl=queue_url, Entries=entries)
if entries:
client.delete_message_batch(QueueUrl=queue_url, Entries=entries)
except Exception as e:
log.exception(e)

0 comments on commit 7fdb8d1

Please sign in to comment.