mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-03 23:37:09 +01:00 
			
		
		
		
	Try a new create task and lower max_messages by half
This commit is contained in:
		@@ -21,9 +21,14 @@ logging.getLogger('sqlalchemy')
 | 
			
		||||
# except raven.exceptions.InvalidDsn:
 | 
			
		||||
#     pass
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    create_task = asyncio.ensure_future
 | 
			
		||||
except AttributeError:
 | 
			
		||||
    create_task = getattr(asyncio, 'async')
 | 
			
		||||
 | 
			
		||||
class Titan(discord.AutoShardedClient):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        super().__init__(max_messages=20000)
 | 
			
		||||
        super().__init__(max_messages=10000)
 | 
			
		||||
        self.aiosession = aiohttp.ClientSession(loop=self.loop)
 | 
			
		||||
        self.http.user_agent += ' TitanEmbeds-Bot'
 | 
			
		||||
        self.redisqueue = RedisQueue(self, config["redis-uri"])
 | 
			
		||||
@@ -63,7 +68,7 @@ class Titan(discord.AutoShardedClient):
 | 
			
		||||
    
 | 
			
		||||
    async def start(self):
 | 
			
		||||
        await self.redisqueue.connect()
 | 
			
		||||
        self.loop.create_task(self.redisqueue.subscribe())
 | 
			
		||||
        create_task(self.redisqueue.subscribe())
 | 
			
		||||
        await super().start(config["bot-token"])
 | 
			
		||||
 | 
			
		||||
    async def on_ready(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,11 @@ import traceback
 | 
			
		||||
import sys
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    create_task = asyncio.ensure_future
 | 
			
		||||
except AttributeError:
 | 
			
		||||
    create_task = getattr(asyncio, 'async')
 | 
			
		||||
 | 
			
		||||
class RedisQueue:
 | 
			
		||||
    def __init__(self, bot, redis_uri):
 | 
			
		||||
        self.bot = bot
 | 
			
		||||
@@ -37,10 +42,7 @@ class RedisQueue:
 | 
			
		||||
        subscriber = await self.sub_connection.start_subscribe()
 | 
			
		||||
        await subscriber.subscribe(["discord-api-req"])
 | 
			
		||||
        count = 0
 | 
			
		||||
        while True:
 | 
			
		||||
            if not self.bot.is_ready() or self.bot.is_closed():
 | 
			
		||||
                await asyncio.sleep(0)
 | 
			
		||||
                continue
 | 
			
		||||
        while not self.bot.is_closed():
 | 
			
		||||
            reply = await subscriber.next_published()
 | 
			
		||||
            request = json.loads(reply.value)
 | 
			
		||||
            resource = request["resource"]
 | 
			
		||||
@@ -54,7 +56,7 @@ class RedisQueue:
 | 
			
		||||
    def dispatch(self, event, key, params):
 | 
			
		||||
        method = "on_" + event
 | 
			
		||||
        if hasattr(self, method):
 | 
			
		||||
            self.bot.loop.create_task(self._run_event(method, key, params))
 | 
			
		||||
            create_task(self._run_event(method, key, params))
 | 
			
		||||
 | 
			
		||||
    async def _run_event(self, event, key, params):
 | 
			
		||||
        try:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user