import sys
import os
from logging import Handler as LoggingHandler


class KillProcessHandler(LoggingHandler):

    @profile
    def emit(self, record):
        if record.levelno != self.level:
            return

        # flush text before exiting
        for fd in [sys.stdout, sys.stderr]:
            fd.flush()

        # Twisted writes unhandled errors in different calls
        # If we exit on the first call, we'd lose the actual error
        for log_to_ignore in ["Unhandled error in Deferred"]:
            if log_to_ignore.lower() in record.getMessage().lower():
                return
        os._exit(1)

@@ -311,16 +311,50 @@
 lush()%0A%0A
+        msg = record.getMessage()%0A
         
@@ -575,35 +575,19 @@
 er() in 
-record.getMessage()
+msg
 .lower()

Remove repetitive getMessage calls in KillProcesshandler