mfenniak / pg8000

A Pure-Python PostgreSQL Driver
http://pythonhosted.org/pg8000/
Other
222 stars 55 forks source link

Possible regression of socket error handling #152

Closed johnarnold closed 5 years ago

johnarnold commented 6 years ago

Possible regression of https://github.com/mfenniak/pg8000/issues/73 and https://github.com/mfenniak/pg8000/commit/97b712a6e4ab00ee48ce9872caae2eead77cea99

It looks like the current code no longer catches socket.error.

Getting BrokenPipeError socket exception bubbling up:

  [E 180202 18:34:04 ioloop:638] Exception in callback functools.partial(<function wrap.<locals>.null_wrapper at 0x7f763a709e18>)
      Traceback (most recent call last):
        File "/usr/local/lib/python3.5/dist-packages/tornado/ioloop.py", line 605, in _run_callback
          ret = callback()
        File "/usr/local/lib/python3.5/dist-packages/tornado/stack_context.py", line 277, in null_wrapper
          return fn(*args, **kwargs)
        File "/usr/local/lib/python3.5/dist-packages/flower/events.py", line 52, in event
          super(EventsState, self).event(event)
        File "/usr/local/lib/python3.5/dist-packages/celery/events/state.py", line 512, in event
          return self._event(event)
        File "/usr/local/lib/python3.5/dist-packages/celery/events/state.py", line 554, in _event
          event_callback(self, event)
        File "/usr/local/lib/python3.5/dist-packages/flower/utils/pg_storage.py", line 47, in event_callback
          json.dumps(event)
        File "/usr/local/lib/python3.5/dist-packages/pg8000/core.py", line 851, in execute
          self._c.execute(self, "begin transaction", None)
        File "/usr/local/lib/python3.5/dist-packages/pg8000/core.py", line 1809, in execute
          self._send_message(BIND, retval)
        File "/usr/local/lib/python3.5/dist-packages/pg8000/core.py", line 1817, in _send_message
          self._write(code)
        File "/usr/lib/python3.5/socket.py", line 593, in write
          return self._sock.send(b)
        File "/usr/lib/python3.5/ssl.py", line 861, in send
          return self._sslobj.write(data)
        File "/usr/lib/python3.5/ssl.py", line 586, in write
          return self._sslobj.write(data)
      BrokenPipeError: [Errno 32] Broken pipe
sanandrea commented 6 years ago

I am having the same issue on the BrokenPipeError exception bubbling up.

...
result = self.conn.execute(query, emp_id=employee_id).fetchone()
  File \"/var/task/sqlalchemy/engine/base.py\", line 945, in execute
    return meth(self, multiparams, params)
  File \"/var/task/sqlalchemy/sql/elements.py\", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File \"/var/task/sqlalchemy/engine/base.py\", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File \"/var/task/sqlalchemy/engine/base.py\", line 1189, in _execute_context
    context)
  File \"/var/task/sqlalchemy/engine/base.py\", line 1405, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File \"/var/task/sqlalchemy/util/compat.py\", line 187, in reraise
    raise value
  File \"/var/task/sqlalchemy/engine/base.py\", line 1182, in _execute_context
    context)
  File \"/var/task/sqlalchemy/engine/default.py\", line 470, in do_execute
    cursor.execute(statement, parameters)
  File \"/var/task/pg8000/core.py\", line 851, in execute
    self._c.execute(self, \"begin transaction\", None)
  File \"/var/task/pg8000/core.py\", line 1812, in execute
    self._flush()
  File \"/var/lang/lib/python3.6/socket.py\", line 604, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe