code: def wrap_with_load_lock(func, redis_params: RedisParams):
      """Redis lock wrapper function for TargetOnKart.load().
      When TargetOnKart.load() is called, redis lock will be locked and released before load().
      https://github.com/m3dev/gokart/issues/265
      """
  
      if not redis_params.should_redis_lock:
          return func
  
      def wrapper(*args, **kwargs):
          redis_lock = _set_redis_lock(redis_params=redis_params)
          scheduler = _set_lock_scheduler(
              redis_lock=redis_lock, redis_params=redis_params
          )
  
          logger.debug(f"Task lock of {redis_params.redis_key} locked.")
          redis_lock.release()
          logger.debug(
              f"Task lock of {redis_params.redis_key} released."
          )
          scheduler.shutdown()
          result = func(*args, **kwargs)
          return result
  
      return wrapper
  
imports: import functools
  import os
  from logging import getLogger
  from typing import Callable, NamedTuple, Optional
  import redis
  from apscheduler.schedulers.background import BackgroundScheduler
label_desc: Use image node_id 7 for calling a global function with example usage: wrap_with_load_lock(func, redis_params) and returns: wrapper, func, result