use process pool + aiofile for /gitpull
@@ -2,6 +2,8 @@ from util.misc import recursive_update
from discord.ext import commands
from typing import Union
import classyjson as cj
+import functools
+import aiofile
import discord
import random
import ast
@@ -84,10 +86,11 @@ class Owner(commands.Cog):
@commands.is_owner()
async def gitpull(self, ctx):
async with ctx.typing():
- os.system("sudo git pull > git_pull_log 2>&1")
+ system_call = functools.partial(os.system, "sudo git pull > git_pull_log 2>&1")
+ await self.bot.loop.run_in_executor(self.bot.ppool, system_call)
- with open("git_pull_log", "r") as f:
- await self.bot.send(ctx, f"```diff\n{f.read()}\n```")
+ async with aiofile.async_open("git_pull_log", "r") as f:
+ await self.bot.send(ctx, f"```diff\n{await f.read()}\n```")
os.remove("git_pull_log")
