code: def guard(func):
      
      semaphore = threading.Lock()
  
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          semaphore.acquire()
          try:
              return func(*args, **kwargs)
          finally:
              semaphore.release()
  
      return wrapper
docs: Prevents the decorated function from parallel execution.
  
       Internally, this decorator creates a Lock object and transparently
       obtains/releases it when calling the function.