add thread to handle picable
This commit is contained in:
10
main.py
10
main.py
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import functools
|
||||
from sys import argv
|
||||
|
||||
import discord
|
||||
@@ -18,7 +19,13 @@ client = commands.Bot(command_prefix="/", intents=intents)
|
||||
|
||||
|
||||
async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str):
|
||||
await interaction.followup.send(PICable.PICable(owner, repo, github_token))
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
result = await loop.run_in_executor(None, functools.partial(PICable.PICable, owner, repo, github_token))
|
||||
await interaction.followup.send(result)
|
||||
except Exception as e:
|
||||
print(f"Error processing PICable check: {e}")
|
||||
await interaction.followup.send("An error occurred while processing your request. Please try again later.")
|
||||
return
|
||||
|
||||
|
||||
@@ -39,5 +46,4 @@ async def picable(interaction: discord.Interaction, owner: str, repository: str)
|
||||
await interaction.response.defer(ephemeral=False, thinking=True)
|
||||
asyncio.create_task(reply_message_async(interaction, owner, repository))
|
||||
|
||||
|
||||
client.run(discord_token)
|
||||
|
||||
Reference in New Issue
Block a user