Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue-based services - add missing sleeps based on queue #5422

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Theodlz
Copy link
Contributor

@Theodlz Theodlz commented Jan 21, 2025

In this PR, we edit the recurring_apis & reminders services to sleep between each iteration. Essentially, if at the end of every processing loop we do not have anything to process in the next 60 seconds, we sleep 60 seconds. If we do have something to process soon, we only sleep until that time. And if the next entry to process should be processed now, then we do not sleep.

This is based on @stefanv's #5415

if next_recurring_api is not None:
dt = (
next_recurring_api.next_call
- datetime.now(timezone.utc).replace(tzinfo=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you re-use now here? Then you also shouldn't need the negativity check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact, you should be able to simply calculate sleep_time directly.

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