Sleep after every subscribe

This commit is contained in:
Jeremy Zhang 2019-03-06 03:11:26 +00:00
parent 6efc5a4b67
commit 4a3d24c5d6

View File

@ -36,7 +36,6 @@ class RedisQueue:
await self.bot.wait_until_ready() await self.bot.wait_until_ready()
subscriber = await self.sub_connection.start_subscribe() subscriber = await self.sub_connection.start_subscribe()
await subscriber.subscribe(["discord-api-req"]) await subscriber.subscribe(["discord-api-req"])
count = 0
while True: while True:
if not self.bot.is_ready() or self.bot.is_closed(): if not self.bot.is_ready() or self.bot.is_closed():
await asyncio.sleep(1) await asyncio.sleep(1)
@ -45,10 +44,6 @@ class RedisQueue:
request = json.loads(reply.value) request = json.loads(reply.value)
resource = request["resource"] resource = request["resource"]
self.dispatch(resource, request["key"], request["params"]) self.dispatch(resource, request["key"], request["params"])
count = count + 1
if count > 10:
count = 0
elif count == 10:
await asyncio.sleep(0) await asyncio.sleep(0)
def dispatch(self, event, key, params): def dispatch(self, event, key, params):