Skip to content

[BUG + REFACTOR] Change behavior of JobQueue.run_monthly #2627

Closed
@Bibo-Joshi

Description

@Bibo-Joshi

Steps to reproduce

  1. job_queue.run_monthly(day=30, day_is_strict=False)

Expected behaviour

Runs on 30th day of each month excluding Feb + on Feb 28th/29th

Actual behaviour

Runs on 30th and 31st day of each month excluding Feb + on Feb 28th/29th

This happens because I didn't pay enough attention when writing this:

else:
trigger = OrTrigger(
[
CronTrigger(
day=day,
hour=when.hour,
minute=when.minute,
second=when.second,
timezone=when.tzinfo,
**job_kwargs,
),
CronTrigger(
day='last',
hour=when.hour,
minute=when.minute,
second=when.second,
timezone=when.tzinfo or self.scheduler.timezone,
**job_kwargs,
),
]
)

However, the use case of day_is_strict is mainly "run on the last day of the month". I therefore suggest to just drop the parameter and instead allow to pass day='last' or day=-1 (I like this one better) to indicate that you want to run the job on the last day of the month.
The use case described above can still be achieved with run_custom.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    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