防止服务器端Python超时?

发布于 2024-12-27 13:03:22 字数 361 浏览 3 评论 0原文

我有一个由 1and1 托管的网站。服务器上有一个包含大约 5,300 张图片的文件夹。我有一个 python 脚本,可以进行一些图像处理。我想对文件夹中的所有图片运行 python 脚本。

我知道让服务器运行脚本的唯一方法是将文件放在我的网站上,然后访问 www.mysite.com/pythonscipt.py

这工作得很好,除了在脚本运行后我收到错误 500 消息只有大约 280 张图片(大约 10 秒后)。我可以运行脚本 20 次,每次运行后删除处理后的图片,但我认为有更好的方法来做到这一点(我只是不知道它是什么)。

问题:这实际上是一个超时错误吗?如果是这样,我可以延长超时时间吗? 或者,是否有更好的方法来运行脚本(这样超时就不会成为问题)?

I have a website hosted by 1and1. On the server there is a folder with about 5,300 pictures. I have a python script that does some image processing. I want to run the python script on all of the pictures in the folder.

The only way I know to make the server run the script is to put the file on my site and then go to www.mysite.com/pythonscipt.py

This works decently, except I get an Error 500 message after the script has gone through only about 280 pictures (after about 10 seconds). I could just run the script 20 times, removing the processed pictures after each run, but I figured there is a better way to do it (I just don't know what it is).

Question: Is this actually a timeout error? If so, can I make the time until timeout longer?
Or, is there a better way to run the script (such that timeouts won't even be an issue)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人心善变 2025-01-03 13:03:22

我建议向托管服务询问此事。一般会有一种在服务器上运行脚本的方法。

I would advise asking the hosting service about it. Generally there will be a way to run scripts on the server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文