fixed last calls to emit that were awaiting

This commit is contained in:
arabcoders 2025-09-12 11:45:22 +03:00
parent 2eba728dd2
commit 63f6ca0cf4
2 changed files with 19 additions and 28 deletions

View file

@ -639,7 +639,7 @@ class DownloadQueue(metaclass=Singleton):
item.template = _preset.template
yt_conf = {}
cookie_file = Path(self.config.temp_path) / f"c_{uuid.uuid4().hex}.txt"
cookie_file: Path = Path(self.config.temp_path) / f"c_{uuid.uuid4().hex}.txt"
LOG.info(f"Adding '{item.__repr__()}'.")
@ -780,16 +780,12 @@ class DownloadQueue(metaclass=Singleton):
self.done.put(dlInfo)
LOG.info(log_message)
await asyncio.gather(
*[
self._notify.emit(Events.LOG_INFO, data={}, title="Ignored Download", message=log_message),
self._notify.emit(
Events.ITEM_MOVED,
data={"to": "history", "preset": dlInfo.info.preset, "item": dlInfo.info},
title="Download History Update",
message=f"Download history updated with '{item.url}'.",
),
]
self._notify.emit(Events.LOG_INFO, data={}, title="Ignored Download", message=log_message)
self._notify.emit(
Events.ITEM_MOVED,
data={"to": "history", "preset": dlInfo.info.preset, "item": dlInfo.info},
title="Download History Update",
message=f"Download history updated with '{item.url}'.",
)
return {"status": "ok"}

View file

@ -431,23 +431,18 @@ class Tasks(metaclass=Singleton):
timeNow = datetime.now(UTC).isoformat()
ended: float = time.time()
LOG.info(f"Task '{task.name}' completed at '{timeNow}' took '{ended - started:.2f}' seconds.")
_tasks = [
self._notify.emit(
Events.TASK_DISPATCHED,
data={**status, "preset": task.preset} if status else {"preset": task.preset},
title=f"Task '{task.name}' dispatched",
message=f"Task '{task.name}' dispatched at '{timeNow}'.",
),
self._notify.emit(
Events.LOG_SUCCESS,
data={"preset": task.preset, "lowPriority": True},
title="Task completed",
message=f"Task '{task.name}' completed in '{ended - started:.2f}'.",
),
]
await asyncio.gather(*_tasks)
self._notify.emit(
Events.TASK_DISPATCHED,
data={**status, "preset": task.preset} if status else {"preset": task.preset},
title=f"Task '{task.name}' dispatched",
message=f"Task '{task.name}' dispatched at '{timeNow}'.",
)
self._notify.emit(
Events.LOG_SUCCESS,
data={"preset": task.preset, "lowPriority": True},
title="Task completed",
message=f"Task '{task.name}' completed in '{ended - started:.2f}'.",
)
except Exception as e:
LOG.error(f"Failed to execute '{task.name}' at '{timeNow}'. '{e!s}'.")
self._notify.emit(