def METHOD_NAME(m):
    # 'm' if the name of the method to override
    def method(self, already_in_loop = False):
        # WARNING: recursive function, so 'already_in_loop' necessary for
        # us to know if we are recursing (True) or not (False)
        NB_DB_CONN_TRY = 2
        # FIXME: NOT YET IMPLEMENTED, but do not implement this using a
        # simple time.sleep(), it would lock the main loop !!!
        #TIME_BTW_CONN_TRY = 0.1 # in seconds, floats are authorized, # pyflakes.ignore
        try: # do a libmysql client call : attempt to perform the old call (_old_<method>)
            old_m = getattr(self, '_old_%s' % m)
            ret = old_m() # success, will send the result back
            return ret # send the result back
        except DBAPIError, e: # failure, catch libmysql client error
            if already_in_loop : # just raise the exception, they will take care of it
                raise e
            # see http://dev.mysql.com/doc/refman/5.1/en/error-messages-client.html
            # we try to handle only situation where a reconnection worth a try
            if e.orig.args[0] == 2013: # Lost connection to MySQL server during query error, but we do not raise the exception (will attempt again)
                logging.getLogger().warn("Lost connection to MySQL server during query")
            elif e.orig.args[0] == 2006: # MySQL server has gone away, but we do not raise the exception (will attempt again)
                logging.getLogger().warn("MySQL server connection has gone away")
            elif e.orig.args[0] == 2002: # Can't contact SQL server, give up
                logging.getLogger().error("MySQL server is unreachable by socket while doing query")
                raise e
            elif e.orig.args[0] == 2003: # Can't contact SQL server, give up
                logging.getLogger().error("MySQL server is unreachable by network while doing query")
                raise e
            else: # Other SQL error, give-up
                logging.getLogger().error("Unknown MySQL error while doing query")
                raise e
            # handle cases where reco can be attempted again
            # this is where things became tricky:
            # we call ourself (new_m) with already_in_loop = True
            # we also silently drop the potentially raised exception
            for i in range(0, NB_DB_CONN_TRY):
                try:
                    new_m = getattr(self, m)
                    ret = new_m(True)
                    return ret
                except Exception, e:
                    pass
            # the loop was unsuccessful, finally raise the original exception
            raise e
    return method