Comments (11)
Exactly the same problem here. I was writing something similar like:
self.update_state(
state = states.FAILURE,
meta = 'Some error message here'
)
# ignore the task so no other state is recorded
raise Ignore()
I'm using:
Django(1.11.7)
Celery(4.1.0)
django-celery-results(1.0.1)
RabbitMQ(3.6.14)
Sqlite3
The problem is: the task's state doesn't change when using django-db
as the backend(CELERY_RESULT_BACKEND = 'django-db'
). More specifically, the task state is always shown as STARTED
on flower but the celery console tells us that the state has been updated and the Ignore
exception had been raised:
[2018-01-07 18:53:54,452: INFO/MainProcess] Received task: webapp.upload.importEventFile[e8ab9bfd-be49-43d2-97da-5d6be2e1a238]
[2018-01-07 18:53:57,768: INFO/ForkPoolWorker-6] Task webapp.upload.importEventFile[e8ab9bfd-be49-43d2-97da-5d6be2e1a238] ignored
from django-celery-results.
I think it's working as designed, but the documentation probably needs some clarification. Especially since store_result
and meta
are fields that are used in different ways in different contexts. Note: I am using the version on master
, labeled as release 1.1.1; not the version on PyPi, labeled as 1.0.1; I highly recommend since the task name has been added to TaskResult, very helpful in identifying which result belongs to which task.
While a task is executing, the TaskResult
is used really as current task state; holding information, temporarily, until the task completes.
So, when celery's update_state
is called from within a task if there is no TaskResult
it is created and the meta
information placed in the results
field and with an updated status. Subsequent calls calls to update_state
update the same TaskResult, overwriting what was there previously.
Upon completion of the task, the results of the task are stored in the same TaskResult, overwriting the previous state of the task: the return from the function in results
and status set to 'SUCCESS' (or 'FAILURE').
The TaskResult's meta
field is used for a different purpose (I believe to capture the results of child tasks?)
TL;DR
celery/app/task.py
calls the store_result
method on the backend , not the manager. It is implemented by super class of django_celery_results.backends.DatabaseBackend
and gets passed off to _store_result
here: https://github.com/celery/django-celery-results/blob/master/django_celery_results/backends/database.py#L16. The backend, in turn, calls store_result
on the manager, with the proper signature within the above method.
http://docs.celeryproject.org/en/latest/userguide/tasks.html#custom-states
@senyuuri as soon as you raise the Ignore exception, the task completes (with a status of 'FAILURE'), sets the traceback and clears the result; any previous state information is no longer, unfortunately. You can test this by putting a time.sleep(5*60)
between the update_state
and raising the Ignore()
and examining the console or database in between.
from django-celery-results.
PR Submitted 😁
from django-celery-results.
I have the same problem, too. After calling update_state
with custom meta object, I can't see the update on the database.
I'm using MySQL as the result backend.
from django-celery-results.
The signature of the function called by update_state
is wrong and needs to be updated:
from django-celery-results.
Is there a way that we can manage the task completed
and total
ourselves? I'm look at a use case where I don't want parallelism, all stuff are done in one single task, and I want to have control over the completed/total value of the task in order to maintain a progress bar in the frontend.
Is this possible in current Celery?
from django-celery-results.
I think it's working as designed, but the documentation probably needs some clarification. Especially since
store_result
andmeta
are fields that are used in different ways in different contexts. Note: I am using the version onmaster
, labeled as release 1.1.1; not the version on PyPi, labeled as 1.0.1; I highly recommend since the task name has been added to TaskResult, very helpful in identifying which result belongs to which task.While a task is executing, the
TaskResult
is used really as current task state; holding information, temporarily, until the task completes.So, when celery's
update_state
is called from within a task if there is noTaskResult
it is created and themeta
information placed in theresults
field and with an updated status. Subsequent calls calls toupdate_state
update the same TaskResult, overwriting what was there previously.Upon completion of the task, the results of the task are stored in the same TaskResult, overwriting the previous state of the task: the return from the function in
results
and status set to 'SUCCESS' (or 'FAILURE').The TaskResult's
meta
field is used for a different purpose (I believe to capture the results of child tasks?)TL;DR
celery/app/task.py
calls thestore_result
method on the backend , not the manager. It is implemented by super class ofdjango_celery_results.backends.DatabaseBackend
and gets passed off to_store_result
here: https://github.com/celery/django-celery-results/blob/master/django_celery_results/backends/database.py#L16. The backend, in turn, callsstore_result
on the manager, with the proper signature within the above method.http://docs.celeryproject.org/en/latest/userguide/tasks.html#custom-states
@senyuuri as soon as you raise the Ignore exception, the task completes (with a status of 'FAILURE'), sets the traceback and clears the result; any previous state information is no longer, unfortunately. You can test this by putting a
time.sleep(5*60)
between theupdate_state
and raising theIgnore()
and examining the console or database in between.
can you please send a doc updating request?
from django-celery-results.
Is there any change to this functionality in the latest version of django-celery-results
. I am facing the same issue as @keeper. The update_state()
is not working for me either.
from django-celery-results.
same issue
from django-celery-results.
Bumped here. Might submit soon a PR with changes to permit the injection of arbitrary data inside the meta
field of TaskResult.
Is it desired?
from django-celery-results.
I'm open to any relevant contribution
from django-celery-results.
Related Issues (20)
- `backend_cleanup` fails when TaskResult is referenced in a model HOT 1
- Can we use django celery results for remote workers?
- Unable to install django_celery_results with Django version 4.2 HOT 1
- Documentation and changelog are out of date HOT 1
- ModuleNotFoundError: No module named 'django_celery_results'
- 'result' cannot be specified for MyTaskResult model form as it is a non-editable field. Check fields/fieldsets/exclude attributes of class MyTaskResultAdmin. HOT 2
- `post_save` signal of TaskResult doesn't trigger HOT 2
- Display the seconds of the datetime fields in the django admin
- Django celery results in combination with dango tenants intermittent error of table not found HOT 2
- Task name, args, and kwargs are not being saved HOT 2
- Building docs fails with Sphinx 7.2 and SOURCE_DATE_EPOCH environment variable
- CELERY_RESULT_EXPIRES does not prevent backend.cleanup task
- date_done does not reflect the time the *task* was completed, but the time the *task result* is updated HOT 1
- Unable to retrieve results across workers HOT 8
- Django 5 support HOT 4
- Getting exception "select_for_update cannot be used outside of a transaction" HOT 2
- persistance for revoked tasks ? HOT 1
- why task name and worker column is always empty HOT 1
- Issue with Django DATABASES CONN_MAX_AGE HOT 1
- call recorder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-celery-results.