From ebe3337823853a61ef0f40a0dcc94f23d5a5f389 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Mon, 26 Aug 2024 22:27:20 -0400 Subject: [PATCH] remove `QueueItem` class --- relay/workers.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/relay/workers.py b/relay/workers.py index 963a54c..31cf4c3 100644 --- a/relay/workers.py +++ b/relay/workers.py @@ -21,12 +21,7 @@ from .misc import IS_WINDOWS, Message, get_app @dataclass -class QueueItem: - pass - - -@dataclass -class PostItem(QueueItem): +class PostItem: inbox: str message: Message instance: Instance | None @@ -40,10 +35,10 @@ class PushWorker(Process): client: HttpClient - def __init__(self, queue: QueueType[QueueItem], log_level: Synchronized[int]) -> None: + def __init__(self, queue: QueueType[PostItem], log_level: Synchronized[int]) -> None: Process.__init__(self) - self.queue: QueueType[QueueItem] = queue + self.queue: QueueType[PostItem] = queue self.shutdown: EventType = Event() self.path: Path = get_app().config.path self.log_level: Synchronized[int] = log_level @@ -80,9 +75,7 @@ class PushWorker(Process): self._log_level_changed.clear() item = self.queue.get(block=True, timeout=0.1) - - if isinstance(item, PostItem): - asyncio.create_task(self.handle_post(item)) + asyncio.create_task(self.handle_post(item)) except Empty: await asyncio.sleep(0) @@ -113,7 +106,7 @@ class PushWorker(Process): class PushWorkers(list[PushWorker]): def __init__(self, count: int) -> None: - self.queue: QueueType[QueueItem] = Queue() + self.queue: QueueType[PostItem] = Queue() self._log_level: Synchronized[int] = Value("i", logging.get_level()) self._count: int = count