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


Groups > comp.lang.python > #96833

Catching exceptions from logging socket handler

Path csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <larry.martell@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; 'handler': 0.04; 'error:': 0.05; 'skip:" 60': 0.05; 'socket': 0.07; 'exceptions,': 0.09; 'retry': 0.09; 'emit': 0.16; 'skip:" 40': 0.20; 'to:name:python-list@python.org': 0.20; 'exceptions': 0.22; 'pipe': 0.22; '(most': 0.24; 'logging': 0.27; 'message- id:@mail.gmail.com': 0.27; 'back.': 0.27; 'call.': 0.30; 'traceback': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'remote': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'close': 0.61; 'side': 0.62
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=STeTKYsQqTD3XDiqbQdZY62q1JaCcm8SPBNOgnSJB4k=; b=I8Hmuw9MNwCbH245TkzBdARRziKK2b0hZFFg7ncDbC1/aPPl9yrlSVZ6qIbSwn6RaF pC0fN7QCZmMBN6jV0vF4SY7/1/qxjWHmmf64krTBt737o82LCyi0zf2J/huswvPLyHk8 6O2Fsr37feNBlj1N7BYXliCpfVjewV7L6rus4T/0n4Jr+kTikfl5fvgbeVD2k9UXsY1n dR/tnOD6mVY3Qd6uDFgVJa/yepAGnB19DOjpl5mGs8DDvdndq+w9wozmkGLfaAB59Uuf w/D/ieXoyzSFvPwKhQHOlAP9703xrbAvDzVrHX0Sm1GPug5gfnctJ+NfL+HWh8gIPryA 6P5w==
MIME-Version 1.0
X-Received by 10.107.166.201 with SMTP id p192mr18062009ioe.0.1442605667311; Fri, 18 Sep 2015 12:47:47 -0700 (PDT)
Date Fri, 18 Sep 2015 15:47:47 -0400
Subject Catching exceptions from logging socket handler
From Larry Martell <larry.martell@gmail.com>
To "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3.1442605674.21674.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442605674 news.xs4all.nl 23844 [2001:888:2000:d::a6]:52184
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96833

Show key headers only | 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