docker 容器 (AWS Lambda) 上的库错误
Library error on docker container (AWS Lambda)
我希望使用在 AWS ECR 上加载的 Docker 容器在 AWS Lambda 上执行 python 脚本。
我设法从他们推荐用于 python 脚本的亚马逊图像开始创建了一个 docker 容器。这是 Docker 文件:
# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}
COPY config.py ${LAMBDA_TASK_ROOT}
COPY abort_occurrance.txt ${LAMBDA_TASK_ROOT}
COPY actions_logging.txt ${LAMBDA_TASK_ROOT}
COPY execution_log.txt ${LAMBDA_TASK_ROOT}
COPY warning_job_occurrance.txt ${LAMBDA_TASK_ROOT}
# Install the function's dependencies using file requirements.txt
# from your project folder.
COPY requirements.txt .
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
CMD ["app.py"]
ENTRYPOINT ["python3"]
如此处所示,app.py 是我的脚本,它必须在容器启动时 运行。
创建图像后,我可以轻松地在本地计算机上启动我的容器,但是当我将其加载到 AWS ECR 并将其 link 加载到 AWS Lambda 时,它将无法工作。
这是 CloudWatch 上返回的错误:
Traceback (most recent call last):
File "app.py", line 2, in <module>
from exchangelib import Credentials, Account
File "/var/task/exchangelib/__init__.py", line 3, in <module>
from .account import Account, Identity
File "/var/task/exchangelib/account.py", line 12, in <module>
from .folders import Folder, AdminAuditLogs, ArchiveDeletedItems, ArchiveInbox, ArchiveMsgFolderRoot, \
File "/var/task/exchangelib/folders/__init__.py", line 16, in <module>
from .roots import Root, ArchiveRoot, PublicFoldersRoot, RootOfHierarchy
File "/var/task/exchangelib/folders/roots.py", line 17, in <module>
class RootOfHierarchy(BaseFolder, metaclass=EWSMeta):
File "/var/task/exchangelib/folders/roots.py", line 26, in RootOfHierarchy
_subfolders_lock = Lock()
File "/var/lang/lib/python3.8/multiprocessing/context.py", line 68, in Lock
return Lock(ctx=self.get_context())
File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 162, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 57, in __init__
sl = self._semlock = _multiprocessing.SemLock(
OSError: [Errno 38] Function not implemented
START RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Version: $LATEST
END RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35
REPORT RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Duration: 3003.57 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 22 MB
2021-09-15T12:52:25.585Z f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Task timed out after 3.00 seconds
容器怎么可能在本地运行 docker 但是当我在 lambda 上测试它时它却不起作用?
谢谢
Lambda 不支持所有运行时的并行处理。这可能就是它在本地工作但在 lambda 中不工作的原因。
https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda/
我希望使用在 AWS ECR 上加载的 Docker 容器在 AWS Lambda 上执行 python 脚本。 我设法从他们推荐用于 python 脚本的亚马逊图像开始创建了一个 docker 容器。这是 Docker 文件:
# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}
COPY config.py ${LAMBDA_TASK_ROOT}
COPY abort_occurrance.txt ${LAMBDA_TASK_ROOT}
COPY actions_logging.txt ${LAMBDA_TASK_ROOT}
COPY execution_log.txt ${LAMBDA_TASK_ROOT}
COPY warning_job_occurrance.txt ${LAMBDA_TASK_ROOT}
# Install the function's dependencies using file requirements.txt
# from your project folder.
COPY requirements.txt .
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
CMD ["app.py"]
ENTRYPOINT ["python3"]
如此处所示,app.py 是我的脚本,它必须在容器启动时 运行。 创建图像后,我可以轻松地在本地计算机上启动我的容器,但是当我将其加载到 AWS ECR 并将其 link 加载到 AWS Lambda 时,它将无法工作。 这是 CloudWatch 上返回的错误:
Traceback (most recent call last):
File "app.py", line 2, in <module>
from exchangelib import Credentials, Account
File "/var/task/exchangelib/__init__.py", line 3, in <module>
from .account import Account, Identity
File "/var/task/exchangelib/account.py", line 12, in <module>
from .folders import Folder, AdminAuditLogs, ArchiveDeletedItems, ArchiveInbox, ArchiveMsgFolderRoot, \
File "/var/task/exchangelib/folders/__init__.py", line 16, in <module>
from .roots import Root, ArchiveRoot, PublicFoldersRoot, RootOfHierarchy
File "/var/task/exchangelib/folders/roots.py", line 17, in <module>
class RootOfHierarchy(BaseFolder, metaclass=EWSMeta):
File "/var/task/exchangelib/folders/roots.py", line 26, in RootOfHierarchy
_subfolders_lock = Lock()
File "/var/lang/lib/python3.8/multiprocessing/context.py", line 68, in Lock
return Lock(ctx=self.get_context())
File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 162, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 57, in __init__
sl = self._semlock = _multiprocessing.SemLock(
OSError: [Errno 38] Function not implemented
START RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Version: $LATEST
END RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35
REPORT RequestId: f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Duration: 3003.57 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 22 MB
2021-09-15T12:52:25.585Z f8056c6e-9ca4-4aba-a1aa-191dca52ea35 Task timed out after 3.00 seconds
容器怎么可能在本地运行 docker 但是当我在 lambda 上测试它时它却不起作用?
谢谢
Lambda 不支持所有运行时的并行处理。这可能就是它在本地工作但在 lambda 中不工作的原因。
https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda/