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
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def __init__(
def uuid(self) -> str:
return self.esm_config["UUID"]

def stop_for_shutdown(self):
# Signal the worker's poller_loop thread to gracefully shutdown
# TODO: Once ESM state is de-coupled from lambda store, re-think this approach.
self._shutdown_event.set()

def create(self):
if self.enabled:
with self._state_lock:
Expand Down
3 changes: 3 additions & 0 deletions localstack-core/localstack/services/lambda_/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ def on_after_init(self):
get_runtime_executor().validate_environment()

def on_before_stop(self) -> None:
for esm_worker in self.esm_workers.values():
esm_worker.stop_for_shutdown()

# TODO: should probably unregister routes?
self.lambda_service.stop()
# Attempt to signal to the Lambda Debug Mode session object to stop.
Expand Down
Loading