Fix author queue stuck

master
dsc 2 years ago
parent 3f5977aa83
commit 0fc93a0192

@ -200,6 +200,10 @@ async def main():
global TASK_AUTHORS, TASK_QUEUE
bot.loop.create_task(bot.connect())
def _lower_author_task_count(task_author):
TASK_AUTHORS.setdefault(task_author, 1)
TASK_AUTHORS[task_author] -= 1
# main loop
while True:
random.shuffle(TASK_QUEUE._queue)
@ -209,12 +213,14 @@ async def main():
images = await task.get_images()
except Exception as ex:
bot.send("PRIVMSG", target=task.channel, message=f"could not fetch images: {ex}")
_lower_author_task_count(task.author)
continue
try:
image = await task.process_images(images)
except Exception as ex:
bot.send("PRIVMSG", target=task.channel, message=f"could not process images: {ex}")
_lower_author_task_count(task.author)
continue
image_bytes = BytesIO()
@ -226,10 +232,10 @@ async def main():
url = await task.post_image(image_bytes)
except Exception as ex:
bot.send("PRIVMSG", target=task.channel, message=str(ex))
_lower_author_task_count(task.author)
continue
TASK_AUTHORS.setdefault(task.author, 1)
TASK_AUTHORS[task.author] -= 1
_lower_author_task_count(task.author)
bot.send("PRIVMSG", target=task.channel, message=f"{url} ({task.author})")
await asyncio.sleep(10)

Loading…
Cancel
Save