【问题标题】:Python error when attempting to run on heroku尝试在heroku上运行时出现Python错误
【发布时间】:2018-05-11 02:11:21
【问题描述】:

我正在尝试将 python 应用程序部署到 heroku。我使用了一个名为 quart(flask 的异步改编)的 web 框架。当我尝试部署时构建成功,但在 heroku 日志中,我收到以下错误消息:

TypeError: __call__() takes 1 positional argument but 3 were

这是运行应用程序的代码:

if __name__ == '__main__': 
     app.run(host='0.0.0.0', port=int(os.environ['PORT']))

我的 procfile 由以下内容组成:

web: gunicorn main_loop:app 

我们将不胜感激。

【问题讨论】:

  • 看起来您在 app.run 调用中缺少一些右括号。
  • @ktzr,哦,对不起,这只是复制和粘贴的错误......
  • @DupDup 您是否仍然收到错误,或者是否已修复?
  • @pushkin 我仍然收到错误消息(我在发这篇文章时没有复制整行代码)。

标签: python heroku flask web-deployment


【解决方案1】:

Quart 需要特定的 Gunicorn 工人类1。我想如果你的 procfile 是

web: gunicorn --worker-class quart.worker.GunicornWorker main_loop:app 

它会起作用的。 (虽然我没有可用于测试的 heroku dyno)。

(我是 Quart 作者)

【讨论】:

  • 它适用于提供网页,但我收到有关 websocket 的 javascript 错误:Mixed Content: The page at 'https://dertio.herokuapp.com/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://dertio.herokuapp.com/ws'. This request has been blocked; this endpoint must be available over WSS. (anonymous) @ (index):266
  • 如果我将浏览器设置为连接到 websocket(websocket 连接因不安全而被阻止),应用程序可以运行,但性能慢得令人难以置信,有什么解决办法吗?
  • 抱歉,没有足够的信息让我回答这两个问题 - 我也无法猜测。
  • websocket 按照您在我的previous question 中的说明运行,但我不知道是什么导致了缓慢(它在 localhost 上运行得很快)。
  • 事实证明,我可以通过将我的 URL 设置为 http 而不是 https 来修复 websocket。我仍然不知道为什么它这么慢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-09
  • 2016-11-19
  • 2013-09-17
相关资源
最近更新 更多