Skip to content

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.

4 participants