code: def wrap_with_dump_lock(
      func: Callable, redis_params: RedisParams, exist_check: Callable
  ):
      """Redis lock wrapper function for TargetOnKart.dump().
      When TargetOnKart.dump() is called, dump() will be wrapped with redis lock and cache existance check.
      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
          )
  
          try:
              logger.debug(
                  f"Task lock of {redis_params.redis_key} locked."
              )
              if not exist_check():
                  func(*args, **kwargs)
          finally:
              logger.debug(
                  f"Task lock of {redis_params.redis_key} released."
              )
              redis_lock.release()
              scheduler.shutdown()
  
      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 6 for calling a global function with example usage: wrap_with_dump_lock(func, redis_params, exist_check) and returns: wrapper, func