防止服务器端Python超时?
我有一个由 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议向托管服务询问此事。一般会有一种在服务器上运行脚本的方法。
I would advise asking the hosting service about it. Generally there will be a way to run scripts on the server.