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


Groups > comp.lang.python > #96833 > unrolled thread

Catching exceptions from logging socket handler

Started byLarry Martell <larry.martell@gmail.com>
First post2015-09-18 15:47 -0400
Last post2015-09-18 15:47 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#96833 — Catching exceptions from logging socket handler

FromLarry Martell <larry.martell@gmail.com>
Date2015-09-18 15:47 -0400
SubjectCatching exceptions from logging socket handler
Message-ID<mailman.3.1442605674.21674.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web