def _do_process_transaction(self, xid, *args, **kwds):
        """Method run by the worker threads to process one transaction"""
        # Call process_transaction and prepare the result to send
        result = None
        try:
            result = ("OK", self.process_transaction(*args, **kwds))
        except Exception, ex:
            ex._trace = traceback.format_exc
            result = ("EXCEPTION", ex)
        except:
            ex = sys.exc_info()[1]
            if ex is not None:
                ex._trace = traceback.format_exc()
            else:
                ex = sys.exc_info()[0]
            result = ("EXCEPTION", ex)
        finally:
            if result is None:
                ex = RuntimeError("Unexpected error !")
                result = ("EXCEPTION", ex)

        # Send response
        self._send((xid, result))

        # Unregister the thread in on-demand mode
        if self.__nworkers is None:
            self.__lock.acquire()
            try:
                # In on-demand mode: unregister the thread for this transaction
                del self.__workers[xid]
            finally:
                self.__lock.release()
Method run by the worker threads to process one transaction
recipes/Python/576520_Multithreaded_MultiplexerDemultiplexer_allow/recipe-576520.py