GithubHelp home page GithubHelp logo

Comments (6)

oortega avatar oortega commented on May 18, 2024 1

Hi, @mghantous apparently the problem comes from your task, this was my case.
By placing close_old_connections () within def store_result (........) I could see that my task in some parts took a long time and the connection with the database was lost, so also within my task place close_old_connections.

So modify store_result (): https://github.com/celery/django-celery-results/blob/master/django_celery_results/managers.py#L87

def store_result(self, content_type, content_encoding,
                 task_id, result, status,
                 traceback=None, meta=None):
    """Store the result and status of a task.
    """
    fields = {
        'status': status,
        'result': result,
        'traceback': traceback,
        'meta': meta,
        'content_encoding': content_encoding,
        'content_type': content_type,
    }
    
    #Fix temporary (2006, 'MySQL server has gone away')
    from django.db import close_old_connections
    close_old_connections()

    obj, created = self.get_or_create(task_id=task_id, defaults=fields)
    if not created:
        for k, v in items(fields):
            setattr(obj, k, v)
        obj.save()
    return obj

I hope I help you, Regards

from django-celery-results.

mghantous avatar mghantous commented on May 18, 2024

It seems to be related to this PR celery/celery#4292
When I get rid of my 'CONN_MAX_AGE': 60 setting, it seems to resolve the issue.

Perhaps I should close the issue and report it on https://github.com/celery/celery instead?

from django-celery-results.

oortega avatar oortega commented on May 18, 2024

@mghantous same issue with:

#celery==4.0.2

amqp==2.1.4
billiard==3.5.0.2
celery==4.0.2
Django==1.11.2
django-celery-beat==1.0.1
django-celery-results==1.0.1
kombu==4.0.2
MySQL-python==1.2.5
pytz==2017.2
vine==1.1.3

After upgrade celery==4.2.1:

amqp==2.3.2
billiard==3.5.0.4
celery==4.2.1
Django==1.11.2
django-celery-beat==1.1.1
django-celery-results==1.0.1
kombu==4.2.1
MySQL-python==1.2.5
pytz==2018.5
redis==2.10.6
vine==1.1.4

from django-celery-results.

mghantous avatar mghantous commented on May 18, 2024

Thank you for the workaround. Hopefully there is a more permanent fix. The task I have been testing doesn't do anything with the database other than have its result be stored (it simply echos a message).

from django-celery-results.

auvipy avatar auvipy commented on May 18, 2024

celery/celery#4292 (comment)

from django-celery-results.

auvipy avatar auvipy commented on May 18, 2024

I hope this is fixed in celery master.

from django-celery-results.

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.