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:
def __init__(self) -> None:
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.idle_action_task = None
async def run_queue(self):
# try:
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])))
action = await self.queued_actions.get()