add typing when generating script

This commit is contained in:
brandons209 2021-03-04 18:52:54 -05:00
parent ce4a52bc19
commit a5ad9c8734

View file

@ -223,26 +223,27 @@ class ScriptGen(commands.Cog):
) )
p.start() p.start()
# in order to avoid the bot's main asyncio loop getting held up (which freezes the bot) async with ctx.typing():
# need to wait while the queue is empty. also cant just put pass, since this # in order to avoid the bot's main asyncio loop getting held up (which freezes the bot)
# will also hold up the bot's main loop # need to wait while the queue is empty. also cant just put pass, since this
# asyncio.sleep(0) forces a context switch which allows other coroutines to continue running and the bot to function normally while the process is ran in a seperate thread # will also hold up the bot's main loop
# see https://stackoverflow.com/questions/63322094/asyncio-aiohttp-create-task-blocks-event-loop-gather-results-in-this-event # asyncio.sleep(0) forces a context switch which allows other coroutines to continue running and the bot to function normally while the process is ran in a seperate thread
while queue.empty(): # see https://stackoverflow.com/questions/63322094/asyncio-aiohttp-create-task-blocks-event-loop-gather-results-in-this-event
await asyncio.sleep(0) while queue.empty():
await asyncio.sleep(0)
# cleanup process # cleanup process
p.join() p.join()
p.close() p.close()
# get output # get output
output = queue.get() output = queue.get()
# unlock and reset cooldown before sending # unlock and reset cooldown before sending
await self.config.guild(ctx.guild).last_ran.set(time.time()) await self.config.guild(ctx.guild).last_ran.set(time.time())
self.unlock_gen() self.unlock_gen()
await ctx.send(box(output)) await ctx.send(box(output))
async def red_delete_data_for_user( async def red_delete_data_for_user(
self, self,