While a lambda is still processing (archive unpacking etc), the lambda state should be set to "Pending" (currently "Active") and invocations to that lambda should fail (currently, it can end up in a inconsistent state in this case, like lambdas being executed without layers).

Lambda state should reflect the current internal state, and invocations should fail if not active.
return importlib.machinery.SourceFileLoader(name, file).load_module()
def exec_lambda_code(script, handler_function="handler", lambda_cwd=None, lambda_env=None):
    
    
    def _do_exec_lambda_code():
        if lambda_cwd or lambda_env:
            if lambda_cwd:
                previous_cwd = os.getcwd()
                os.chdir(lambda_cwd)
                sys.path = [lambda_cwd] + sys.path
            if lambda_env:
                previous_env = dict(os.environ)
                os.environ.update(lambda_env)
        
        lambda_id = "l_%s" % short_uid()
        lambda_file = LAMBDA_SCRIPT_PATTERN.replace("*", lambda_id)
        save_file(lambda_file, script)
        
        TMP_FILES.append(lambda_file)
        TMP_FILES.append("%sc" % lambda_file)
        try:
            pre_sys_modules_keys = set(sys.modules.keys())