【问题标题】:Discord.py raise RuntimeError('Task is already launched and is not completed.')Discord.py raise RuntimeError('任务已启动但未完成。')
【发布时间】:2021-09-08 10:56:33
【问题描述】:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 94, in on_ready
    update_fetch.start()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 205, in start

raise RuntimeError('Task is already launched and is not completed.')

RuntimeError: Task is already launched and is not completed.

有人知道为什么会这样吗?我的bot已经运行了1个月,然后突然每隔一段时间就会出现这种情况,虽然它只影响bot的状态,但所有的bot功能都很好

【问题讨论】:

    标签: python discord discord.py bots


    【解决方案1】:

    由于您在on_ready 中启动任务,可以调用多次,当第二次调用on_ready 时,您会收到此错误。 为了防止这种情况,您可以简单地检查任务是否已经开始:

    #change update_fetch.start() to:
    if not update_fetch.is_running():
        update_fetch.start() 
    

    来源:

    如果这对您不起作用,您能否在帖子中包含on_readyupdate_fetch 的代码

    【讨论】:

      猜你喜欢
      • 2016-09-21
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      相关资源
      最近更新 更多