From bfcc7d20b3621d47a6c1452a5688fd34251643b4 Mon Sep 17 00:00:00 2001 From: Artem Isakhanian <80114098+Temik26@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:21:32 +0300 Subject: [PATCH 1/2] Avoid duplication of task execution (#319) --- docs/framework_integrations/taskiq-with-aiogram.md | 2 +- taskiq/cli/scheduler/run.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/framework_integrations/taskiq-with-aiogram.md b/docs/framework_integrations/taskiq-with-aiogram.md index 3a4e684..d10682d 100644 --- a/docs/framework_integrations/taskiq-with-aiogram.md +++ b/docs/framework_integrations/taskiq-with-aiogram.md @@ -67,7 +67,7 @@ bot = Bot(token="TOKEN") @dp.startup() async def setup_taskiq(bot: Bot, *_args, **_kwargs): # Here we check if it's a clien-side, - # Becuase otherwise you're going to + # Because otherwise you're going to # create infinite loop of startup events. if not broker.is_worker_process: logging.info("Setting up taskiq") diff --git a/taskiq/cli/scheduler/run.py b/taskiq/cli/scheduler/run.py index 6a17a11..be4bdd1 100644 --- a/taskiq/cli/scheduler/run.py +++ b/taskiq/cli/scheduler/run.py @@ -144,9 +144,6 @@ async def run_scheduler_loop(scheduler: TaskiqScheduler) -> None: running_schedules = set() while True: # We use this method to correctly sleep for one minute. - next_minute = datetime.now().replace(second=0, microsecond=0) + timedelta( - minutes=1, - ) scheduled_tasks = await get_all_schedules(scheduler) for source, task_list in scheduled_tasks.items(): for task in task_list: @@ -165,7 +162,9 @@ async def run_scheduler_loop(scheduler: TaskiqScheduler) -> None: ) running_schedules.add(send_task) send_task.add_done_callback(running_schedules.discard) - + next_minute = datetime.now().replace(second=0, microsecond=0) + timedelta( + minutes=1, + ) delay = next_minute - datetime.now() await asyncio.sleep(delay.total_seconds()) From a35b086676f73be4bb16426f434baeee544b4933 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Fri, 26 Apr 2024 22:07:31 +0200 Subject: [PATCH 2/2] Bumped version to 0.11.2. Signed-off-by: Pavel Kirilin --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c76c7a0..ce4ad02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "taskiq" -version = "0.11.1" +version = "0.11.2" description = "Distributed task queue with full async support" authors = ["Pavel Kirilin "] maintainers = ["Pavel Kirilin "]