Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96833

Catching exceptions from logging socket handler

Date 2015-09-18 15:47 -0400
Subject Catching exceptions from logging socket handler
From Larry Martell <larry.martell@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3.1442605674.21674.python-list@python.org> (permalink)

Show all headers | View raw


I have a socket logging handler and I want to be able to catch
exceptions from it. Specifically, I want to know if the remote side
has gone away so I can close the socket and reopen it when the remote
side come back.

What happens now is that I get Broken pipe and BAD_WRITE_RETRY
exceptions, but it's not coming from any functions I directly call. is
there any way to catch these?

Traceback (most recent call last):
  File "/home/ecovent/python2.7.9/lib/python2.7/logging/handlers.py",
line 579, in emit
    self.send(s)
  File "/home/ecovent/python2.7.9/lib/python2.7/logging/handlers.py",
line 520, in send
    self.sock.sendall(s)
  File "/home/ecovent/python2.7.9/lib/python2.7/ssl.py", line 701, in sendall
    v = self.send(data[count:])
  File "/home/ecovent/python2.7.9/lib/python2.7/ssl.py", line 667, in send
    v = self._sslobj.write(data)
SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1625)

Traceback (most recent call last):
  File "/home/ecovent/python2.7.9/lib/python2.7/logging/handlers.py",
line 579, in emit
    self.send(s)
  File "/home/ecovent/python2.7.9/lib/python2.7/logging/handlers.py",
line 520, in send
    self.sock.sendall(s)
  File "/home/ecovent/python2.7.9/lib/python2.7/ssl.py", line 701, in sendall
    v = self.send(data[count:])
  File "/home/ecovent/python2.7.9/lib/python2.7/ssl.py", line 667, in send
    v = self._sslobj.write(data)
error: [Errno 32] Broken pipe

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Catching exceptions from logging socket handler Larry Martell <larry.martell@gmail.com> - 2015-09-18 15:47 -0400

csiph-web