def code_exec(self, code, extra_environ=None, debug=False):
        # define the execution environment
        environdict = {"settings_module": settings}
        environ = "settings_module.configure()"
        if extra_environ:
            for key, value in extra_environ.items():
                environdict[key] = value

        # initializing the django settings at the top of code
        code = "# auto-added by Evennia\n" \
               "try: %s\n" \
               "except RuntimeError: pass\n" \
               "finally: del settings_module\n%s" % (environ, code)

        # execute the block
        try:
            exec(code, environdict)
        except Exception:
            etype, value, tb = sys.exc_info()

            fname = tb_filename(tb)
            for tb in tb_iter(tb):
                if fname != tb_filename(tb):
                    break
            lineno = tb.tb_lineno - 1
            err = ""
            for iline, line in enumerate(code.split("\n")):
                if iline == lineno:
                    err += "\n{w%02i{n: %s" % (iline + 1, line)
                elif lineno - 5 < iline < lineno + 5:
                    err += "\n%02i: %s" % (iline + 1, line)

            err += "\n".join(traceback.format_exception(etype, value, tb))
            return err
        return None
Return a new consumer stats counter instance.
dataset/ETHPy150Open evennia/evennia/evennia/utils/batchprocessors.py/BatchCodeProcessor.code_exec--crossover with--dataset/ETHPy150Open gmr/rejected/rejected/mcp.py/MasterControlProgram.consumer_stats_counter