I'm currently trying to create a script which handles multiple Blender command prompt renders in a queue, while at the same running a discord bot in the background which responds with the elapsed time ETA and other stuff when using a !progress command.
However, when I tried running them one after another, it seemed that the program doesn't do anything more after the bot is started. When I looked online it said that it is because it's an event loop and before the bot function gets stopped the code does not proceed.
Here is my code if anyone asks later:
Discord bot:
import asyncio
import discord
from discord.ext import commands
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.command()
async def progress(ctx):
progress_message = 'SAMPLE PROGRESS MESSAGE'
await ctx.send(progress_message)
async def run_bot():
await bot.start('BOT_TOKEN_HERE')
def main():
bot.run('YOUR_DISCORD_BOT_TOKEN')
if __name__ == '__main__':
main()
The portion which handles the rendering is a giant while loop which waits until one file is finished, moves on to the next one, and so on until at the end of rendering a file the number of the file is equal to the total number of renders (I can share the code if someone wants to)
I tried using 'asyncio.gather()', but this is my first time using asyncio so it either gave me an error "... attached to a different loop" or the programmes ran sequentially, which as I described already does not work.
I don't know where to go from here, that's why I'm asking this question.
Any help will be appreciated, even if someone links a (suitable) tutorial.