“在查询python期间失去与MySQL服务器的连接

时间:2018-07-27 22:30:21

标签: mysql python-3.x

我正在使用@transaction.atomic decorator 我正在使用python和django 我得到了这个错误:

Internal Server Error: /create_project
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 422, in commit
    self._read_ok_packet()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 396, in _read_ok_packet
    pkt = self._read_packet()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 656, in _read_packet
    packet_header = self._read_bytes(4)
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 702, in _read_bytes
    CR.CR_SERVER_LOST, "Lost connection to MySQL server during query")
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.4/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.4/dist-packages/django/db/transaction.py", line 212, in __exit__
    connection.commit()
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 261, in commit
    self._commit()
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
  File "/usr/local/lib/python3.4/dist-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.4/dist-packages/django/db/backends/base/base.py", line 239, in _commit
    return self.connection.commit()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 422, in commit
    self._read_ok_packet()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 396, in _read_ok_packet
    pkt = self._read_packet()
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 656, in _read_packet
    packet_header = self._read_bytes(4)
  File "/usr/local/lib/python3.4/dist-packages/pymysql/connections.py", line 702, in _read_bytes
    CR.CR_SERVER_LOST, "Lost connection to MySQL server during query")
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')

我该怎么办?? UPD:我正在使用cloud 9 ide(c9.io),因为c9服务器不够健壮,这是否可以与性能问题联系起来?

0 个答案:

没有答案