Discord.py: Run BOT and Dashboard at the same time

Created on 28 Jul 2020  路  2Comments  路  Source: Rapptz/discord.py

Summary

I'm trying to run my bot and dashboard at the same time to use discord.py within the dashboard. I am using the function create_task() but it is not going, when it loads the events, commands and modules of the BOT the terminal ends.

Reproduction Steps

[my code.......]
async def rundashboard():
    await client.wait_until_ready()
    while not client.is_closed():
        os.environ['FLASK_APP'] = "dashboard.py"
        os.environ['FLASK_ENV'] = "development"
        os.environ['FLASK_DEBUG'] = "1"
        app.run(host="0.0.0.0", port=5000)


if "__name__" == "__main__":
    #client.loop.create_task(rundashboard())
    client.run(settings.token)

Expected Results

Actual Results

Printscreen

Checklist

  • [x] I have searched the open issues for duplicates.
  • [x] I have shown the entire traceback, if possible.
  • [x] I have removed my token from display, if visible.

System Information

  • Python v3.8.1-final
  • discord.py v1.4.0-alpha

    • discord.py pkg_resources: v1.4.0a2409+gb77af19

  • aiohttp v3.6.2
  • system info: Windows 10 10.0.19041
invalid off-topic

Most helpful comment

This is indeed how blocking works. Using create_task does not magically turn synchronous code asynchronous. The general recommended way to handle something like this is either separate these two applications entirely, or use an asynchronous framework.

Note that this is not really the place to ask for help using the library, or general Python issues (as this is just a misunderstanding of how asyncio works). If you want more help with discord.py things you should join the discord server

All 2 comments

This is indeed how blocking works. Using create_task does not magically turn synchronous code asynchronous. The general recommended way to handle something like this is either separate these two applications entirely, or use an asynchronous framework.

Note that this is not really the place to ask for help using the library, or general Python issues (as this is just a misunderstanding of how asyncio works). If you want more help with discord.py things you should join the discord server

This is not an issue with discord.py.
GitHub issues for this repository should be used to report issues with this library.
They are not a medium for requesting help with Python.
For further help specific to using this library, you should join either the official discord.py server or the Discord API server

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rimmy50 picture Rimmy50  路  3Comments

TunaHobby picture TunaHobby  路  3Comments

JackL0 picture JackL0  路  3Comments

j0hnmeow picture j0hnmeow  路  3Comments

AraHaan picture AraHaan  路  3Comments