AWSLambda: Ensure simple backend does not require docker-module (#7000)

This commit is contained in:
Bert Blommers 2023-11-07 21:48:26 -01:00 committed by GitHub
parent 060b10974f
commit 366a5f594f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -7,8 +7,6 @@ from gzip import GzipFile
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
from sys import platform from sys import platform
import docker
import docker.errors
import hashlib import hashlib
import io import io
import logging import logging
@ -157,6 +155,8 @@ class _DockerDataVolumeContext:
with self.__class__._lock: with self.__class__._lock:
self._vol_ref.refcount -= 1 # type: ignore[union-attr] self._vol_ref.refcount -= 1 # type: ignore[union-attr]
if self._vol_ref.refcount == 0: # type: ignore[union-attr] if self._vol_ref.refcount == 0: # type: ignore[union-attr]
import docker.errors
try: try:
self._vol_ref.volume.remove() # type: ignore[union-attr] self._vol_ref.volume.remove() # type: ignore[union-attr]
except docker.errors.APIError as e: except docker.errors.APIError as e:
@ -240,6 +240,8 @@ class _DockerDataVolumeLayerContext:
with self.__class__._lock: with self.__class__._lock:
self._vol_ref.refcount -= 1 # type: ignore[union-attr] self._vol_ref.refcount -= 1 # type: ignore[union-attr]
if self._vol_ref.refcount == 0: # type: ignore[union-attr] if self._vol_ref.refcount == 0: # type: ignore[union-attr]
import docker.errors
try: try:
self._vol_ref.volume.remove() # type: ignore[union-attr] self._vol_ref.volume.remove() # type: ignore[union-attr]
except docker.errors.APIError as e: except docker.errors.APIError as e:
@ -857,6 +859,9 @@ class LambdaFunction(CloudFormationModel, DockerModel):
return s return s
def _invoke_lambda(self, event: Optional[str] = None) -> Tuple[str, bool, str]: def _invoke_lambda(self, event: Optional[str] = None) -> Tuple[str, bool, str]:
import docker
import docker.errors
# Create the LogGroup if necessary, to write the result to # Create the LogGroup if necessary, to write the result to
self.logs_backend.ensure_log_group(self.logs_group_name) self.logs_backend.ensure_log_group(self.logs_group_name)
# TODO: context not yet implemented # TODO: context not yet implemented

View File

@ -102,6 +102,7 @@ appsync = graphql-core
athena = athena =
autoscaling = autoscaling =
awslambda = docker>=3.0.0 awslambda = docker>=3.0.0
awslambda_simple =
batch = docker>=3.0.0 batch = docker>=3.0.0
batch_simple = batch_simple =
budgets = budgets =