Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions localstack-core/localstack/services/sqs/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
from localstack.services.edge import ROUTER
from localstack.services.plugins import ServiceLifecycleHook
from localstack.services.sqs import constants as sqs_constants
from localstack.services.sqs.constants import HEADER_LOCALSTACK_SQS_OVERRIDE_MESSAGE_COUNT
from localstack.services.sqs.constants import (
HEADER_LOCALSTACK_SQS_OVERRIDE_MESSAGE_COUNT,
)
from localstack.services.sqs.exceptions import InvalidParameterValueException
from localstack.services.sqs.models import (
FifoQueue,
Expand Down Expand Up @@ -192,7 +194,7 @@ def __init__(self, num_thread: int = 3):
)

def shutdown(self):
self.executor.shutdown(wait=False)
self.executor.shutdown(wait=False, cancel_futures=True)

def dispatch_sqs_metric(
self,
Expand Down Expand Up @@ -468,7 +470,7 @@ def close(self):
for move_task in self.move_tasks.values():
move_task.cancel_event.set()

self.executor.shutdown(wait=False)
self.executor.shutdown(wait=False, cancel_futures=True)

def _run(self, move_task: MessageMoveTask):
try:
Expand Down
2 changes: 2 additions & 0 deletions localstack-core/localstack/services/sqs/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def __init__(self, maxsize=0):

def get(self, block=True, timeout=None):
with self.not_empty:
if self.is_shutdown:
raise Empty
Comment on lines +15 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why we need this at the beginning here as well?

Copy link
Contributor Author

@gregfurman gregfurman Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just allows for an earlier exit if we enter the poll loop in the time it takes between shutdown() being called and get() being called. Just a very minor optimisation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are for example also not raising exceptions on timeouts < 0 in this case here, but that might not be all too important.

if not block:
if not self._qsize():
raise Empty
Expand Down
Loading