Skip to content

Conversation

@danfimov
Copy link
Contributor

@danfimov danfimov commented Oct 22, 2025

Added optional update_schedule method for ScheduleSource.

This method will be simpler to use than delete and then recreate.

Copilot AI review requested due to automatic review settings October 22, 2025 17:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an optional update_schedule method to the ScheduleSource abstract base class, enabling schedule sources to support updating existing schedules. This enhancement provides a standardized interface for modifying scheduled tasks, similar to the existing add_schedule and delete_schedule methods.

  • Added update_schedule method to ScheduleSource ABC with comprehensive documentation
  • Implemented example usage in the schedule source documentation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
taskiq/abc/schedule_source.py Added update_schedule method to the abstract base class with NotImplementedError for sources that don't support updates
docs/examples/extending/schedule_source.py Added example implementation of update_schedule method demonstrating its usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


# This method is optional. You may not implement this.
# It's just a helper to people to be able to interact with your source.
async def update_schedule(self, schedule: "ScheduledTask") -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call delete and create in this method? Isn't it enough? Why do we need a separate method in each result_backend?

Copy link
Contributor Author

@danfimov danfimov Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be easier for library user to call one method instead of two. Like in this case for example: https://github.com/orgs/taskiq-python/discussions/535

And in postgres schedule source for example I will do delete + create in one transaction to not accidentally break something in case of connection error between two operations. Without this method user should think about it in his code and can even forget about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants