crython
crython copied to clipboard
using minute= only assumes second='*'
I just want to check in on this one, as I expect a different behaviour.
From the docs, we have:
# fire every 10 seconds
@crython.job(second=range(0,60,10))
which is true and good behaviour. However from that I expected the same use for minutes:
# fire every 10 minutes
@crython.job(minute=range(0,60,10))
But as second= defaults to '*', we actually get:
# fire every second of every 10th minute
@crython.job(minute=range(0,60,10))
Is this intended?
@MrMathias
Thanks for the good question. I do agree that this has somewhat of a high astonishment factor.
The work-around is .job(second=0, minute=range(0, 60, 10))
but definitely a valid question if wildcard should be the default.
I don't believe cron proper has any prior art/guidance in this case as it requires you to specify the entire expression and can't do partials.
Least astonishment would be that if you specify a single field, all lesser fields get defaulted to zero in that case. However, I'm not sure I like that either because you're specifying an individual field, not an expression. If the keyword arg was named minutely?
instead of minute
(hourly vs. hour) I'd feel stronger about changing it.
Anyways, lots of thoughts/rambling. Thanks for the question, it's got the gears churning. I'll think more about it. For now, I'd just stick to the work-around.