remove QueueItem class

This commit is contained in:
Izalia Mae 2024-08-26 22:27:20 -04:00
parent cff3bc30b8
commit ebe3337823

View file

@ -21,12 +21,7 @@ from .misc import IS_WINDOWS, Message, get_app
@dataclass @dataclass
class QueueItem: class PostItem:
pass
@dataclass
class PostItem(QueueItem):
inbox: str inbox: str
message: Message message: Message
instance: Instance | None instance: Instance | None
@ -40,10 +35,10 @@ class PushWorker(Process):
client: HttpClient 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) Process.__init__(self)
self.queue: QueueType[QueueItem] = queue self.queue: QueueType[PostItem] = queue
self.shutdown: EventType = Event() self.shutdown: EventType = Event()
self.path: Path = get_app().config.path self.path: Path = get_app().config.path
self.log_level: Synchronized[int] = log_level self.log_level: Synchronized[int] = log_level
@ -80,9 +75,7 @@ class PushWorker(Process):
self._log_level_changed.clear() self._log_level_changed.clear()
item = self.queue.get(block=True, timeout=0.1) item = self.queue.get(block=True, timeout=0.1)
asyncio.create_task(self.handle_post(item))
if isinstance(item, PostItem):
asyncio.create_task(self.handle_post(item))
except Empty: except Empty:
await asyncio.sleep(0) await asyncio.sleep(0)
@ -113,7 +106,7 @@ class PushWorker(Process):
class PushWorkers(list[PushWorker]): class PushWorkers(list[PushWorker]):
def __init__(self, count: int) -> None: 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._log_level: Synchronized[int] = Value("i", logging.get_level())
self._count: int = count self._count: int = count