nginx + uwsgi 502 错误网关 python

发布于 2024-12-07 13:26:21 字数 307 浏览 1 评论 0原文

我正在 python 中运行一个脚本,需要很长时间来处理。问题是,如果该函数需要很长时间才能运行,我猜 nginx 在其配置中存在超时,这可以防止某种错误,并阻止该函数完全运行。

我只是想知道是否可以增加超时值。因为我已经尝试了 nginx 文件conf中的一些命令,例如:

uwsgi_connect_timeout 75;
uwsgi_send_timeout 75;
uwsgi_read_timeout 75;
keepalive_timeout 650;

但是这些命令都不起作用。

提前致谢

I'm running a script in python and takes a long time to process. The thing is if the function takes to long to run, i guess the nginx has a timeout, in his configuration and that prevents somekind of errors, and prevents the function to run completely.

I just want to know were i can increse the value of the timeout. Because i've tried some commands in the file conf of nginx such as:

uwsgi_connect_timeout 75;
uwsgi_send_timeout 75;
uwsgi_read_timeout 75;
keepalive_timeout 650;

but none of this worked.

Thks in advance

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

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

发布评论

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

评论(3

左耳近心 2024-12-14 13:26:21

仅仅延长超时的问题是,无论您将其设置多长,您都会在某个地方遇到限制。使用网络服务器、浏览器或地理编码调用。如果某个请求通常会失败 n 次,那么您就无法真正做出任何保证。

因此,与其让客户端请求挂在长时间运行的进程上(并通过扩展冒服务器超时的风险),为什么不使用类似 celery 运行这些地理编码任务,并在客户端通过 JavaScript 提交客户端请求,并通过 ajax 直到得到响应?

The problem with just extending the timeout is that no matter how much longer you set it to you will run into limitations somewhere along the line. Either with the web server, the browser or your geocode calls. If it is something that routinely fails n times in a request, then you can't really make any guarantees.

So rather than having the client request hanging on a long running process (and by extension risking a server timeout), why don't you use something like celery to run those geocode tasks and on the client-side, submit your client-side request via javascript and poll the server for the answer via ajax until it get's a response?

骷髅 2024-12-14 13:26:21

我在 NGIX + uWSGI 配置中也遇到了错误的网关错误,并且为了那些用 google 搜索这个问题的人:它可能缺少 uwsgi python 插件。请参阅:uWSGI 配置问题:uwsgi 失败,没有任何错误消息。

I also had Bad gateway error in NGIX + uWSGI configuration, and for sake of people who google this question: it might be missing uwsgi python plugin. Please see: uWSGI configuration issue: uwsgi fails without any error message..

旧故 2024-12-14 13:26:21

我尝试了上面的回复以及其他地方写的所有内容,但它们不起作用。

我的解决方案是更改 uwsgi.conf 和 nginx.conf 文件中的套接字。

I tried everything written in the above response as well as other places but they did not work.

My solution was changing my socket in both the uwsgi.conf and nginx.conf files.

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