Giter VIP home page Giter VIP logo

Comments (6)

czue avatar czue commented on June 16, 2024

Thanks for this issue! I'll try and set out some time to look into it in the next few weeks.

from celery-progress.

OmarWKH avatar OmarWKH commented on June 16, 2024

I'm not sure it's a race condition. The initial state should be "PENDING" or "STARTED" even if set_progress() isn't called.

The error message indicates this is caused by an unknown state (in which case this is related to #54). It would be helpful to know what state caused the error. Do you have a way to check the task state when the error happens? If not, I made PR #82 to log unknown states and show them in the "Uh-Oh" message.

from celery-progress.

im4bacon avatar im4bacon commented on June 16, 2024

What I saw was that if I created a ProgressRecorder and didn't set_progress until later, I could see that state was occasionally coming back as null and then within a few seconds I'd see it going to PENDING state.. But by that time, I already had the "uh-oh" message.

As soon as I added a set_progress just below my creation of the ProgressRecorder, I haven't had the problem since.
progress_recorder = ProgressRecorder(self)
progress_recorder.set_progress(0, 1, description='Querying solutions...')

from celery-progress.

OmarWKH avatar OmarWKH commented on June 16, 2024

That's odd. I'm unable to reproduce the issue with this setup:
python 3.8, redis 5.0, packages:

  • celery-progress==0.1.0
  • celery==5.0.5
  • Django==3.1.7
  • redis==3.5.3

The task:

@shared_task(bind=True)
def http_task(self, number):
    progress_recorder = ProgressRecorder(self)
    for i in range(number):
        time.sleep(.1)
    return random()*1000

The view:

def http_view(request):
    result = http_task.apply_async(kwargs={'number':15})
    return render(request, 'http.html', context={'task_id': result.task_id})

Is your application similar? Any other notable thing that could be related (celery config, progress bar template)?
Also, where did you see that the state was null?

from celery-progress.

im4bacon avatar im4bacon commented on June 16, 2024

This doesn't happen often, and I just can't figure out how to reproduce it. But I added some console logs to hopefully give a little more info for you.

this.onTaskError(this.progressBarElement, this.progressBarMessageElement, data.result);

In celery_progress.js, in the function onData(), I'm falling into the case where data.complete === true and data.success === false. data.state does not equal RETRY, so I'm hitting the else onTaskError(). Even though the task did complete successfully.

{state: "PROGRESS", complete: true, success: false, progress: {…}, result: "Unknown state { <> }"
state: "PROGRESS"
success: false

data.progress looks like
{pending: false, current: 0, total: 100, percent: 0}

from celery-progress.

OmarWKH avatar OmarWKH commented on June 16, 2024

{state: "PROGRESS", complete: true, success: false, progress: {…}, result: "Unknown state { <> }"

Interesting. I'm not sure how this response was made, but I have a theory.

This response is produced when a state is unknown. See here.

But 'PROGRESS' is a known state, and there's an "else if" clause that produces a proper response for it:

elif self.result.state == PROGRESS_STATE:

The only thing I can think of is that the state (self.result.state) changed midway. It was 'PROGRESS' at first, then it changed to an unknown state. So self.result.state had different values in these two lines:

response = {'state': self.result.state}

elif self.result.state == PROGRESS_STATE:

Is that possible? If it's, a fix would be to store the state once and use the stored value throughout the method instead of asking for it in each clause.

I'm also not sure what the unknown state is. It'll be logged and shown in the page if you use the unpublished version of celery-progress from github (by installing "git+https://github.com/czue/celery-progress@master#egg=celery-progress" or putting it in your requirements file).

from celery-progress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.