mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Limit the queue to 50 payloads
This commit is contained in:
parent
8a4addaf63
commit
c77233ab98
1 changed files with 11 additions and 2 deletions
|
@ -61,7 +61,8 @@ class Events(commands.Cog):
|
|||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.http = httpx.AsyncClient()
|
||||
self.bot.bridge_queue = asyncio.Queue()
|
||||
if not hasattr(self.bot, "bridge_queue") or self.bot.bridge_queue.empty():
|
||||
self.bot.bridge_queue = asyncio.Queue(50)
|
||||
self.fetch_discord_atom_feed.start()
|
||||
|
||||
def cog_unload(self):
|
||||
|
@ -383,7 +384,15 @@ class Events(commands.Cog):
|
|||
for a in message.attachments
|
||||
]
|
||||
}
|
||||
try:
|
||||
self.bot.bridge_queue.put_nowait(payload)
|
||||
except asyncio.QueueFull:
|
||||
_m = await message.reply(
|
||||
"There's over 50 messages waiting to be bridged, slow the fuck down!",
|
||||
)
|
||||
print("Queue overload!")
|
||||
await self.bot.bridge_queue.put(payload)
|
||||
await _m.delete(delay=0.01)
|
||||
print("Added %s to queue" % payload)
|
||||
|
||||
if message.channel.name == "pinboard":
|
||||
|
|
Loading…
Reference in a new issue