From d2c27753b7786b86138c9bb67706fec2a67bb542 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 21 Feb 2023 15:41:45 +0100 Subject: [PATCH] Batch: Fix "local variable 'containers' referenced before assignment". (#5953) --- moto/batch/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/moto/batch/models.py b/moto/batch/models.py index 5bd751ab8..97ea23945 100644 --- a/moto/batch/models.py +++ b/moto/batch/models.py @@ -606,7 +606,12 @@ class Job(threading.Thread, BaseModel, DockerModel, ManagedState): """ try: import docker + except ImportError as err: + logger.error(f"Failed to run AWS Batch container {self.name}. Error {err}") + self._mark_stopped(success=False) + return + try: containers: List[docker.models.containers.Container] = [] self.advance()