class_docstr: Have one place to retrieve data from Yahoo API in order to ease caching and speed up operations.
  Singleton means one session one cookie shared by all threads.
class_docstr_tok: ["Have","one","place","to","retrieve","data","from","Yahoo","API","in","order","to","ease","caching","and","speed","up","operations",".","Singleton","means","one","session","one","cookie","shared","by","all","threads","."]
code: def _set_cookie_strategy(self, strategy, have_lock=False):
      if strategy == self._cookie_strategy:
          return
      if not have_lock:
          self._cookie_lock.acquire()
  
      try:
          if self._cookie_strategy == "csrf":
              utils.get_yf_logger().debug(
                  f"toggling cookie strategy {self._cookie_strategy} -> basic"
              )
              self._session.cookies.clear()
              self._cookie_strategy = "basic"
          else:
              utils.get_yf_logger().debug(
                  f"toggling cookie strategy {self._cookie_strategy} -> csrf"
              )
              self._cookie_strategy = "csrf"
          self._cookie = None
          self._crumb = None
      except Exception:
          self._cookie_lock.release()
          raise
  
      if not have_lock:
          self._cookie_lock.release()
  
imports: import functools
  from functools import lru_cache
  import requests
  from bs4 import BeautifulSoup
  import datetime
  from frozendict import frozendict
  from .None import utils, cache
  import threading
label_desc: Use image node_id 3 for calling the YfData obj's underlying member method code with example usage: obj._set_cookie_strategy(strategy, have_lock) without return types