【发布时间】:2019-08-27 03:21:34
【问题描述】:
我目前正在构建一个 Flask 应用程序,我在其中使用 python discord API 来监听命令并返回简单的消息。
bot = commands.Bot(command_prefix="!", description="Bot")
@bot.command()
async def ping(ctx):
await ctx.send('%s PONG' % ctx.message.author.mention)
bot.run(BOT_TOKEN)
同时,我在“/”处提供网页,但是当我尝试进入该网页时,该网页只是挂起。我使用 gunicorn 使用命令“gunicorn -b 0.0.0.0:8080 --chdir application/site/main:app --reload --log-level=DEBUG”启动我的烧瓶应用程序,并在输出中得到
[2019-08-26 23:17:04 -0400] [50370] [INFO] Starting gunicorn 19.9.0
[2019-08-26 23:17:05 -0400] [50370] [DEBUG] Arbiter booted
[2019-08-26 23:17:05 -0400] [50370] [INFO] Listening at: http://0.0.0.0:8080 (50370)
[2019-08-26 23:17:05 -0400] [50370] [INFO] Using worker: sync
[2019-08-26 23:17:05 -0400] [50373] [INFO] Booting worker with pid: 50373
[2019-08-26 23:17:05 -0400] [50370] [DEBUG] 1 workers
[2019-08-26 23:17:08 -0400] [50373] [INFO] Logged in as Discord Bot 603846646383509504
[2019-08-26 23:17:35 -0400] [50370] [CRITICAL] WORKER TIMEOUT (pid:50373)
[2019-08-26 23:17:35 -0400] [50373] [INFO] Worker exiting (pid: 50373)
[2019-08-26 23:17:35 -0400] [50374] [INFO] Booting worker with pid: 50374
[2019-08-26 23:17:37 -0400] [50374] [INFO] Logged in as Discord Bot 603846646383509504
discord bot 工作正常,但加载网页却不行。我是否遗漏了我的烧瓶应用程序同时服务两个请求的东西,还是这是预期的行为?
【问题讨论】:
-
client.run被阻止,这可能会导致您的网页无法加载。见这里:discordpy.readthedocs.io/en/latest/api.html#discord.Client.run -
啊,明白了。感谢 API 参考! @Benjin
标签: python flask gunicorn discord.py