Working with kronos

133 views
Skip to first unread message

Joel Mathew

unread,
Nov 22, 2018, 2:49:30 AM11/22/18
to django...@googlegroups.com
I was trying the basic django-kronos command to test:
I did pip3 install django-kronos,

myproject/myapp/cron.py:
import kronos
import random

@kronos.register('* * * * *')
def complain():
complaints = [
"I forgot to migrate our applications's cron jobs to our new server! Darn!",
"I'm out of complaints! Damnit!"
]

print random.choice(complaints)

In my myproject/myproject/settings.py:

INSTALLED_APPS = [
'appointments.apps.AppointmentsConfig',
'clinic.apps.ClinicConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'bootstrap4',
'widget_tweaks',
'parsley',
'session_security',
'kronos'
]

Ran:
./manage.py runserver
I expected the dev server to throw up a message every minute. Nothing seems to be happening.

Sincerely yours,

 Joel G Mathew

Jason

unread,
Nov 22, 2018, 8:11:36 AM11/22/18
to Django users
https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron

sounds like you need to run a register management command first.

Joel Mathew

unread,
Nov 22, 2018, 9:05:34 AM11/22/18
to django...@googlegroups.com
I understood the documentation to mean that either we can create management commands and register with cronos, or create cron.py.

Sincerely yours,

 Joel G Mathew


On Thu, 22 Nov 2018 at 18:42, Jason <jjohn...@gmail.com> wrote:
https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron

sounds like you need to run a register management command first.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bc4a5948-8e8d-45c8-8a7c-522e482680bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason

unread,
Nov 22, 2018, 10:36:08 PM11/22/18
to Django users
the documentation is ambiguous in that regard.  that said, I feel it says you can register the cron tasks either way, but it doesn't do anything to actually install the commands.  you can see the code of the installtasks management command:



as you can see there, it uses the python crontab package to install the crontab task.

Furthermore, in https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114, you can see what exactly the decorator consists of.  It just adds the task to a task registry set and doesn't do anything about actual installation.

as an aside, one of the things I've found to be pretty valuable is to look at the project repository when it comes to questions like this.  this is not meant to be mean, and I'm sorry if it comes across that way.  I didn't know about this project before your question, but a brief look in the repo revealed those links and functions above, which are the most likely answers to your question above.  you're asking good questions here and giving good help in return, so if you internalize a method of investigating problems like this, or have more specific and focused questions that your investigations have unearthed.

Joel

unread,
Nov 22, 2018, 10:41:46 PM11/22/18
to django...@googlegroups.com
Yes, the language of the documentation certainly needs tweaking. I had done the installtasks and it did work. Thank you very much for your help.
Now, I can have my app check for upcoming appointments and send reminders. It was a much needed functionality.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Joel

unread,
Nov 22, 2018, 10:46:46 PM11/22/18
to django...@googlegroups.com
Thanks for the advise regarding understanding the issue in depth. My initiation to python has been all of three months, and to django since two. So far, I'd been scared to look under the hood, and any further than the documentation. But I realize that it's not as daunting now add it used to be. And coming from perl, I'm impressed at how cleaner it is. 

Now I'm feeling power packed to examine the innards of django and python. Thank you! 

On Fri, 23 Nov, 2018, 9:06 AM Jason <jjohn...@gmail.com wrote:
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jason

unread,
Nov 23, 2018, 8:50:21 AM11/23/18
to Django users
:-)  Good!  I know it can be intimidating, have been there a few times before.  But it gets easier the more you do it!
Reply all
Reply to author
Forward
0 new messages