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

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.

Does anyone know why this keeps going on? My bot has been running fine for 1 month then suddenly it appears like this every once in a while, although it only affects the status of the bot, all the bot functions are fine

0

1 Answer

Since you start the task in on_ready, which could be called multiplie times, when on_ready is called the second time, you get this error. To prevent this, you could simply check if the task is already started:

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

Sources:

If this doesn't work for you, could you include the code of on_ready and update_fetch in your post

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like