[Zope3-checkins] SVN: Zope3/trunk/src/zope/server/linereceiver/lineserverchannel.py close_when_done() when handling errors, rather than close()

Shane Hathaway shane at zope.com
Mon Sep 6 21:32:54 EDT 2004


Log message for revision 27458:
  close_when_done() when handling errors, rather than close()
  


Changed:
  U   Zope3/trunk/src/zope/server/linereceiver/lineserverchannel.py


-=-
Modified: Zope3/trunk/src/zope/server/linereceiver/lineserverchannel.py
===================================================================
--- Zope3/trunk/src/zope/server/linereceiver/lineserverchannel.py	2004-09-07 01:32:04 UTC (rev 27457)
+++ Zope3/trunk/src/zope/server/linereceiver/lineserverchannel.py	2004-09-07 01:32:54 UTC (rev 27458)
@@ -19,6 +19,7 @@
 $Id$
 """
 
+from asyncore import compact_traceback
 import os
 import sys
 
@@ -106,6 +107,27 @@
         # TODO: Some logging should go on here.
 
 
+    def handle_error_no_close(self):
+        """See asyncore.dispatcher.handle_error()"""
+        nil, t, v, tbinfo = compact_traceback()
+
+        # sometimes a user repr method will crash.
+        try:
+            self_repr = repr(self)
+        except:
+            self_repr = '<__repr__(self) failed for object at %0x>' % id(self)
+
+        self.log_info(
+            'uncaptured python exception, closing channel %s (%s:%s %s)' % (
+                self_repr,
+                t,
+                v,
+                tbinfo
+                ),
+            'error'
+            )
+
+
     def exception(self):
         if DEBUG:
             import traceback
@@ -116,4 +138,5 @@
         except:
             info = str(t)
         self.reply('INTERNAL_ERROR', info)
-        self.handle_error()
+        self.handle_error_no_close()
+        self.close_when_done()



More information about the Zope3-Checkins mailing list