This commit is contained in:
Maximilian Giller 2024-01-30 20:04:01 +01:00
parent 1094fce783
commit 44890aced6

View file

@ -5,14 +5,14 @@ from typing import Optional
class ActionQueue: class ActionQueue:
def __init__(self) -> None: def __init__(self) -> None:
self.queued_actions: asyncio.Queue = asyncio.Queue() self.queued_actions: asyncio.Queue = asyncio.Queue()
self.idle_action: Optional[any] = None self.idle_action: tuple = (None,[],{})
self.queue_task = asyncio.create_task(self.run_queue()) self.queue_task = asyncio.create_task(self.run_queue())
self.idle_action_task = None self.idle_action_task = None
async def run_queue(self): async def run_queue(self):
# try: # try:
while True: while True:
if self.queued_actions.empty() and self.idle_action is not None: if self.queued_actions.empty() and self.idle_action[0] is not None:
self.idle_action_task = asyncio.create_task(self.idle_action[0](*(self.idle_action[1]), **(self.idle_action[2]))) self.idle_action_task = asyncio.create_task(self.idle_action[0](*(self.idle_action[1]), **(self.idle_action[2])))
action = await self.queued_actions.get() action = await self.queued_actions.get()