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

daily task only runs with --force #9

Open
luisnabais opened this issue Oct 1, 2014 · 2 comments
Open

daily task only runs with --force #9

luisnabais opened this issue Oct 1, 2014 · 2 comments

Comments

@luisnabais
Copy link

Hi there.

I need some help, I think this will be very fast for you to help.
I've installed django-periodically 0.3.0 using pip, yesterday.

I added 'periodically' to INSTALLED_APPS.
I have an app called corporate, in which I created a periodictasks.py file, in which I have:

from periodically.decorators import *

import logging
import os

@daily(hour=10, minute=58)
def check_domain_expiration_task():
"<task_code_here>"

and in crontab I have:
57 10 * * * /usr/bin/python /usr/local/aurora-framework/manage.py runtasks

Nothing runs.
I've tried the same time in both, earlier time in each one and still nothing.
If I run manually "python manage.py runtasks", nothing happens, but if I run "python manage.py runtasks --force", the task runs and works correctly.

Any hint on what is causing this issue?

Thanks a lot for your time and help.
Best regards,
Luís Nabais

@nealclark
Copy link

I have run into the same issue. Can you check the periodically_executionrecord table. My suspicion is that you will find a task with completed_successfully = false and end_time = null. If such a record exists django_periodically probably outputs a message along the lines of "There are still tasks running; no new tasks will be run".

I think I have tracked the issue into incorrect database transaction useagle. Each task and it's execution record should be run in a database single transaction. This would ensure that, in the event or an error, the database is left in a consistent state.

Thoughts?

@nealclark
Copy link

The check_timeout(...) function check to see if a task with a specific task_id has timed out.
https://github.com/hzdg/django-periodically/blob/master/periodically/backends.py#L114

However the next line in _run_tasks(...) check to see if any task has not completed.
https://github.com/hzdg/django-periodically/blob/master/periodically/backends.py#L88

Because the check at line 88 causes _run_tasks() to return check_timeout() will never be called on subsequent tasks. If the offending task is not the first one checked execution will always stop.

Depending on the overall behaviour desired there are two ways to solve the problem. If no other task should run if any task is running then the check_timeout() function should check the timeout on all tasks not just a specific one. The other option is to add the same task_id check to the filter at line 88. This would mean that any individual task can not run concurrently.

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

No branches or pull requests

2 participants