django ConnectionError: Error 104 while writing to socket. Connection reset by peer

created at 07-17-2021 views: 32

django ConnectionError: Error 104 while writing to socket Connection reset by peer:

Internal Server Error: /api/v2/chenxm/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/chenxinming/StructureSearchViews/", line 27, in post
    data =, concept_name, startPos, endPos)
  File "/home/chenxinming/StructureSearch/", line 546, in run
    data = self.getObjectData(union_obj_keys, type)
  File "/home/chenxinming/StructureSearch/", line 462, in getObjectData
    concept_map = Object.bulkGetObjectConcept(obj_keys)
  File "/home/chenxinming/", line 868, in bulkGetObjectConcept
    concept_li = p.execute()
  File "/usr/local/lib/python2.7/dist-packages/redis/", line 2894, in execute
    return execute(conn, stack, raise_on_error)
  File "/usr/local/lib/python2.7/dist-packages/redis/", line 2810, in _execute_pipeline
  File "/usr/local/lib/python2.7/dist-packages/redis/", line 603, in send_packed_command
    (errno, errmsg))
ConnectionError: Error 104 while writing to socket. Connection reset by peer.

After inspection and investigation, it was found that the amount of data obtained by redis was too large, which caused redis to interrupt the connection.

with cache.pipeline(transaction=False) as p:
    for english_name in english_li:
        p.hget(keyName._getConceptNameTable(), english_name)
    concept_li = p.execu

The reason is that when using the pipeline, the length of english_li exceeds 10w. Modify the number of lengths to limit english_li.

created at:07-17-2021
edited at: 07-17-2021: