I am currently working on a Discord bot using the discord.py library (rewrite version) and plan to deploy it on several servers simultaneously.
My inquiry is as follows:
Is it necessary to create a distinct thread for each server, or does the bot implement a queue system to process events sequentially? If it utilizes a queue, is it better to rely on that mechanism or to establish separate threads?
I apologize if this seems like a beginner’s question; I’m still learning the ins and outs of discord.py.
Thank you for your attention!
hey! discord.py handles incoming events in a single thread, so it utilizes asyncio’s event loop to process tasks asynchronously. usually, bots manage fine with this, unless ur handling lots of tasks simultaneously, then u might need separate threads, but asyncio should cover most cases! gl with ur bot
:bust_in_silhouette:
From my experience, managing events across multiple servers can often be efficiently handled using the asyncio event loop that is built into discord.py. This allows the bot to execute tasks asynchronously, which helps in dealing with many events without needing separate threads. However, if your bot is dealing with very heavy workloads or specifics tasks that require parallel execution, you might consider using threads or multiprocessing. Always monitor your bot’s performance and tweak the implementation according to the specific needs of your application.