Fixing error when stop and return too fast, because of that there may be some threads downloading songs that will try to put songs in a already closed queue

This commit is contained in:
Rafael Vargas
2023-01-25 13:07:39 -03:00
parent 8dfa3579ae
commit afb223eadd
12 changed files with 51 additions and 15 deletions

View File

@@ -1,4 +1,6 @@
from abc import ABC, abstractmethod
from Parallelism.Commands import VCommands
from multiprocessing import Queue
from typing import List, Union
from discord.ext.commands import Context
from discord import Client, Guild, ClientUser, Interaction, Member, User
@@ -27,6 +29,12 @@ class AbstractHandler(ABC):
else:
self.__author = ctx.user
def putCommandInQueue(self, queue: Queue, command: VCommands) -> None:
try:
queue.put(command)
except Exception as e:
print(f'[ERROR PUTTING COMMAND IN QUEUE] -> {e}')
@abstractmethod
async def run(self) -> HandlerResponse:
pass