Skip to content

jobqueue: add support for specifying next_t in datetime.datetime or datetime.time #482

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

Closed
wants to merge 3 commits into from

Conversation

jh0ker
Copy link
Member

@jh0ker jh0ker commented Dec 13, 2016

Title says it all, I guess. Many people asked for it, so here we go. You can now specify the next_t parameter of JobQueue.put as datetime.datetime or datetime.time, so the job will run at exactly the specified (date and) time.

>>> from datetime import datetime, time, timedelta
>>> job_queue.put(happy_new_year_job, next_t=datetime(2017, 1, 1))
>>> job_queue.put(alarm_clock_job, next_t=time(8, 30))
>>> midnight_job = Job(midnight_callback, timedelta(days=1))
>>> job_queue.put(midnight_job, next_t=time(0, 0))

If you pass a datetime.time object for next_t and it's already later than the specified time (eg it's 10:00 and next_t is time(8, 30)), the job will execute the next day.

I made the interval parameter for Job optional, so you can just leave it for non-repeating jobs (however, you must explicitly pass repeat=False)

@jh0ker jh0ker added enhancement 📋 pending-review work status: pending-review labels Dec 13, 2016
@jh0ker
Copy link
Member Author

jh0ker commented Dec 13, 2016

Related to #452

Copy link

@evieluvsrainbows evieluvsrainbows left a comment

Choose a reason for hiding this comment

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

Looks great to me 👍

@jh0ker
Copy link
Member Author

jh0ker commented Dec 18, 2016

closing in favour of #484

@jh0ker jh0ker closed this Dec 18, 2016
@rahiel rahiel deleted the jobqueue-absolute branch February 5, 2017 22:28
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2020
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement 📋 pending-review work status: pending-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy