Flask App, die nach 60 Sekunden Leerlaufzeit "MySQL Server zurückgelegt" hat

Ich verwende Flask-SQLAlchemy in meiner App und nach 60 Sekunden Leerlaufzeit kehrt MySQL einen "MySQL Server ist weg" Fehler.

Hier ist mein Rückblick:

Traceback (most recent call last): File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app response = self.full_dispatch_request() File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request rv = self.handle_user_exception(e) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/flask/app.py", line 1356, in full_dispatch_request rv = self.preprocess_request() File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/flask/app.py", line 1539, in preprocess_request rv = func() File "./project/controllers/__init__.py", line 18, in set_domain_and_config \ current_site = Site.query.filter(Site.url == host).first_or_404() File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/flask_sqlalchemy.py", line 367, in first_or_404 rv = self.first() File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2181, in first ret = list(self[0:1]) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2048, in __getitem__ return list(res) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2252, in __iter__ return self._execute_and_instances(context) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2267, in _execute_and_instances result = conn.execute(querycontext.statement,\ self._params) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 664, in execute params) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 764, in _execute_clauseelement compiled_sql, distilled_params File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 878, in _execute_context context) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 871, in _execute_context context) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 320, in do_execute cursor.execute(statement, parameters) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/newrelic-1.10.0.28/newrelic/hooks/database_dbapi2.py", line 36, in execute return self._nr_cursor.execute(sql, *args, **kwargs) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute self.errorhandler(self, exc, value) File "/var/www/vhosts/example.com/httpdocs/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (OperationalError) (2006, 'MySQL server has gone away') 

One Solution collect form web for “Flask App, die nach 60 Sekunden Leerlaufzeit "MySQL Server zurückgelegt" hat”

60 Sekunden scheinen eine niedrige Zahl, aber Sie können SQLALCHEMY_POOL_RECYCLE in Ihrem Anwendungs-config setzen, um <60 Sekunden zu sein, wenn Ihr Server mehr aggressiv tötet Leerlaufverbindungen.

  • Wie kann man die Anzahl der Verbindungen mit SQLAlchemy + postgreSQL reduzieren?
  • Konnte den Dialekt für SQlite nicht ermitteln, nach dem Flaschen-Tutorial
  • Wie komme ich nach zahlreicher Vielfalt in SQLAlchemy?
  • Cross-Datenbank beitreten in sqlalchemy
  • SQLAlchemy - Durchführen einer Bulk-upsert (falls vorhanden, Update, sonst einfügen) in postgresql [duplicate]
  • Wie baue ich eine Flasche Anwendung um eine bereits vorhandene Datenbank?
  • Flask API empfängt keine Pläne plötzlich
  • Sqlalchemy mehrere Fremdschlüssel zu der gleichen Tabelle
  • SQLAlchemy links mit Unterabfrage
  • Sqlalchemy ausländische Schlüsselbeziehung Attribute
  • SQLAlchemy ORM Umwandlung in Pandas DataFrame
  • Python ist die beste Programmiersprache der Welt.