Skip to content
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

ValueError: hour must be in 0..23 when using start_at='once' between 2300-2400 hrs. #4

Open
gordol opened this issue Mar 5, 2016 · 4 comments · May be fixed by #5
Open

ValueError: hour must be in 0..23 when using start_at='once' between 2300-2400 hrs. #4

gordol opened this issue Mar 5, 2016 · 4 comments · May be fixed by #5

Comments

@gordol
Copy link

gordol commented Mar 5, 2016

When starting the scheduler between the hours of 11PM and 12AM while using start_at='once'causes the following exception to be thrown:

Traceback (most recent call last):
  File "~/.virtualenvs/test/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "~/.virtualenvs/test/lib/python2.7/site-packages/greenclock/__init__.py", line 166, in run
    delay = task.timer.next().total_seconds()
  File "~/.virtualenvs/test/lib/python2.7/site-packages/greenclock/__init__.py", line 102, in next
    return scheduled.replace(hour=now_.hour + 1) - now_
ValueError: hour must be in 0..23
<Greenlet at 0x10ec51690: <bound method Scheduler.run of <greenclock.Scheduler object at 0x10ed22d90>>(<greenclock.Task object at 0x10ed22ed0>)> failed with ValueError

Here is my code, very simple:

import greenclock
import gevent
from foo import task
scheduler = greenclock.Scheduler(logger_name='task_scheduler')
scheduler.schedule('task', greenclock.every_hour(hour=0, minute=0, second=0), task)

def run_scheduler():
    print "running scheduler"
    scheduler.run_forever(start_at='once')

gevent.spawn(run_scheduler)

I need to run a job at midnight.

For now, I am able to work around it via `start_at='tomorrow' and setting it to run in the first seconds of the day like this:

import greenclock
import gevent
from foo import task
scheduler = greenclock.Scheduler(logger_name='task_scheduler')
scheduler.schedule('task', greenclock.every_hour(hour=0, minute=0, second=5), task)

def run_scheduler():
    print "running scheduler"
    scheduler.run_forever(start_at='tomorrow')

gevent.spawn(run_scheduler)

Is this known and expected behavior? Seems like a bug to me...

Thanks!

@gordol gordol linked a pull request Mar 5, 2016 that will close this issue
@pcdinh
Copy link
Owner

pcdinh commented Mar 14, 2016

Hi,

Many thanks for your bug report. I am really sorry for late report. For unknown reasons, GitHub didn't send any notification to me.

As of your report, I will check it soon.

Thanks

@gordol
Copy link
Author

gordol commented Mar 14, 2016

👍

@gordol
Copy link
Author

gordol commented Mar 31, 2016

@pcdinh There is also a problem with last day of month... similar error:

return scheduled.replace(day=now_.day + 1) - now_
ValueError: day is out of range for month

@gordol
Copy link
Author

gordol commented Oct 6, 2016

@pcdinh is this repository maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants