Skip to content

Commit 25d4d82

Browse files
authored
[SQS] Improve shutdown capabilities of SqsProvider (#12252)
1 parent 57aeecb commit 25d4d82

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

localstack-core/localstack/services/sqs/provider.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ def __init__(self, num_thread: int = 3):
193193
self.executor = ThreadPoolExecutor(
194194
num_thread, thread_name_prefix="sqs-metrics-cloudwatch-dispatcher"
195195
)
196+
self.running = True
196197

197198
def shutdown(self):
198199
self.executor.shutdown(wait=False, cancel_futures=True)
200+
self.running = False
199201

200202
def dispatch_sqs_metric(
201203
self,
@@ -215,6 +217,9 @@ def dispatch_sqs_metric(
215217
:param value The value for that metric, default 1
216218
:param unit The unit for the value, default "Count"
217219
"""
220+
if not self.running:
221+
return
222+
218223
self.executor.submit(
219224
publish_sqs_metric,
220225
account_id=account_id,
@@ -1060,6 +1065,8 @@ def delete_queue(self, context: RequestContext, queue_url: String, **kwargs) ->
10601065
queue.region,
10611066
queue.account_id,
10621067
)
1068+
# Trigger a shutdown prior to removing the queue resource
1069+
store.queues[queue.name].shutdown()
10631070
del store.queues[queue.name]
10641071
store.deleted[queue.name] = time.time()
10651072

0 commit comments

Comments
 (0)