added 'unexpected communication error' fix to ChangeLog. Added formatExceptionInfo to server/asyncserver.py

We should move that function to a helpers module.


git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_8@739 a942ae1a-1317-0410-a47c-b1dcaea8d605
This commit is contained in:
Arturo 'Buanzo' Busleiman
2009-08-30 13:51:17 +00:00
parent b2f0bfe751
commit 81e2fe8306
2 changed files with 18 additions and 1 deletions

View File

@@ -30,6 +30,19 @@ import asyncore, asynchat, socket, os, logging, sys
# Gets the instance of the logger.
logSys = logging.getLogger("fail2ban.server")
# we should move this to some sort of helper functions module
def formatExceptionInfo():
""" Author: Arturo 'Buanzo' Busleiman """
import sys
cla, exc = sys.exc_info()[:2]
excName = cla.__name__
try:
excArgs = exc.__dict__["args"]
except KeyError:
excArgs = str(exc)
return (excName, excArgs)
##
# Request handler class.
#
@@ -69,7 +82,9 @@ class RequestHandler(asynchat.async_chat):
self.close_when_done()
def handle_error(self):
logSys.error("Unexpected communication error")
e1,e2 = formatExceptionInfo()
logSys.error("Unexpected communication error: "+e2)
logSys.error(traceback.format_exc().splitlines())
self.close()
##