简体   繁体   English

AWS Lambda 存储问题

[英]AWS Lambda storage issue

I got the following error when I ran python code on AWS lambda.当我在 AWS lambda 上运行 python 代码时出现以下错误。

"errorMessage": "[Errno 17] File exists: '/tmp/testdir/'"

It occurs on the line os.makedirs('/tmp/testdir/') .它出现在os.makedirs('/tmp/testdir/')行。

Before I didn't have this kind of error.之前我没有这种错误。 Does this mean Lambda function preserves tmp directory?这是否意味着 Lambda function 保留了 tmp 目录?

Should I clean tmp directory everytime?我应该每次都清理 tmp 目录吗?

Yes, the content of the Lambda diskspace at /tmp may be available to subsequent Lambda invocations (these are so-called 'warm start' invocations).是的,位于/tmp的 Lambda 磁盘空间的内容可用于后续的 Lambda 调用(这些是所谓的“热启动”调用)。

SeeUnderstanding Container Reuse .请参阅了解容器重用

You can clean up the /tmp folder before existing your Lambda function or you could use the following code to safely create the folder, ignoring the fact that it may already exist:您可以在存在 Lambda function 之前清理/tmp文件夹,或者您可以使用以下代码安全地创建文件夹,忽略它可能已经存在的事实:

os.makedirs('/tmp/testdir/', exist_ok=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM