zoukankan      html  css  js  c++  java
  • 【MySQL】MySQL server has gone away 怎么处理?

    直接上代码:

    from django.db import connection
    ...
    def is_connection_usable():
        try:
            connection.connection.ping()
        except:
            return False
        else:
            return True
    ...
    
    def do_work():
        while(True): # Endless loop that keeps the worker going (simplified)
            if not is_connection_usable():
                connection.close()
            try:
                do_a_bit_of_work()
            except:
                logger.exception("Something bad happened, trying again")
                sleep(1)

    参考资料:

    http://luruoyu.blog.51cto.com/2876338/788315

    https://code.djangoproject.com/ticket/21597

    http://stackoverflow.com/questions/14163429/python-and-django-operationalerror-2006-mysql-server-has-gone-away

    http://stackoverflow.com/questions/7835272/django-operationalerror-2006-mysql-server-has-gone-away

    https://github.com/celery/django-celery/issues/359

  • 相关阅读:
    NOI2015 小园丁和老司机
    退役记
    留言板
    $mathfrak {reputation}$
    计算几何基础
    HNOI2018简要题解
    JXOI2018简要题解
    BJOI2018简要题解
    HAOI2018 简要题解
    CQOI2018简要题解
  • 原文地址:https://www.cnblogs.com/junneyang/p/6146045.html
Copyright © 2011-2022 走看看