We usually set the period to 0 for tasks that run only once.
Hence, the period should not matter at all.
This works fine, unless you also set the prevent_drift to True -- this causes the division by zero.
I agree that it is a bit silly to set prevent_drift=True for a task that runs only once.
I also believe it makes sense to make the code more robust.
I think it is quite easy to fix this in the code as I mentioned in the initial post.
See the diff in attached screenshot:
The 'next_run_time' doesn't matter when it's a one-time task, so it can be initialized outside of the condition.
And recalculating it using task.period only makes sense if task.period is bigger than 0.