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

Latest version with pip install django-carrot #95

Closed
tehfink opened this issue Sep 2, 2018 · 4 comments
Closed

Latest version with pip install django-carrot #95

tehfink opened this issue Sep 2, 2018 · 4 comments

Comments

@tehfink
Copy link

tehfink commented Sep 2, 2018

Following the directions here yesterday:
http://www.django-carrot.com/en/latest/quick-start.html

After installing with pip install django-carrot in a virtualenv with Django 2.1.1, I spent a few hours debugging why this error constantly popped up when creating a new ScheduledTask with the task_name kwarg:
django.db.utils.IntegrityError: UNIQUE constraint failed: carrot_scheduledtask.task_name

Apparently the most recent released version installed via pip is 6a5fbb3, which is behind the fix in 5bdfc14. Checking carrot.__version__ returns '0'.
Will there be a new release soon, or what's the recommended version of carrot to install?

@chris104957
Copy link
Owner

Is this on a clean install or are you upgrading from a previous version of carrot?

@chris104957
Copy link
Owner

The root cause here is that you are trying to create a ScheduledTask object with a non-unique task_name value. By default, when you create a new ScheduledTask object using the carrot.utilities.create_scheduled_task function, if you do not provide the task_name value, this will automatically default to the name of the task function you are trying to schedule (e.g. my_app.my_tasks.my_task). So, if you already have a ScheduledTask object for one function, and you try to create another one for the same function, without specifying the task_name parameter, this will cause this error.

Solution: Use the task_name parameter when using carrot.utilities.create_scheduled_task:

create_scheduled_task('my_app.my_tasks.task`, {'seconds': 5}, task_name='something unique', **task_kwargs)

I'm going to add validation to that function for version 1.3 so that its more clear in future what the issue is.

The version number thing is a weird issue that seems to have arisen from CI, this will also be fixed in 1.3

@chris104957
Copy link
Owner

Fixed with #97

@tehfink
Copy link
Author

tehfink commented Sep 3, 2018

Thanks for the reply, and a great project!

Is this on a clean install or are you upgrading from a previous version of carrot?

A fresh install & in a new virtualenv.

Solution: Use the task_name parameter when using carrot.utilities.create_scheduled_task…

Thanks, I had seen this in the docs and was looking forward to trying it out! The problem was that the version of carrot installed via pip install django-carrot didn't include the task_name kwarg from 5bdfc14. Anyway, it has been 'fixed' by telling pip which changeset to install, e.g.:

pip install git+git://github.com/chris104957/django-carrot.git@ded8daa8edf66ffe06829ec064df15aa676c5567#egg=django-carrot

@tehfink tehfink closed this as completed Sep 3, 2018
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