【问题标题】:"504 Gateway Timeout" while executing python cgi script执行 python cgi 脚本时出现“504 网关超时”
【发布时间】:2020-03-21 05:52:03
【问题描述】:

以下示例代码:

#!/usr/bin/python3
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation, get_body

print('Content-Type:text/html;charset=utf-8\n')

t = Time("2014-09-22 23:22")
loc = EarthLocation.of_site('greenwich') 
with solar_system_ephemeris.set('builtin'):
    jup = get_body('jupiter', t, loc) 
print('<h2>',jup.ra.deg,'</h2>')  

脚本在本地运行时可以正常工作 (=136.9111620895066)。但如果我尝试从服务器执行它,则会出现“504 Gateway Time-out”Nginx 错误。

也许 astropy 保存星历表数据的文件有问题?其他 astropy、matplotlib 等脚本在服务器上运行良好。每次脚本需要 ephemerides flles (jpl, esa ...) 时都会出现该错误。

【问题讨论】:

  • 你也可以发布你的 Nginx 配置吗?
  • 你是如何调用这个脚本的(例如客户端——Nginx——脚本)?该错误意味着 Nginx 正在等待响应以返回给客户端(或调用此脚本的任何人),但您的脚本没有提供响应(即它只是 prints 到标准输出)。
  • isn't print('

    ',jup.ra.deg,'

    ') 应该将

    标签内的结果返回给客户端?

标签: python nginx astropy


【解决方案1】:

确保您拥有 astropy 的最新错误修复版本(v3.2.3,http://docs.astropy.org/en/latest/changelog.html#id153),因为它修复了 IERS URL 的问题,这可能是您“504 Gateway Time-out”错误的原因。

【讨论】:

    猜你喜欢
    • 2013-12-13
    • 2013-11-16
    • 2015-07-29
    • 1970-01-01
    • 2019-12-02
    • 1970-01-01
    • 2013-09-04
    • 2013-05-20
    相关资源
    最近更新 更多