code: def setlocale(name):
      
      with LOCALE_LOCK:
          old_locale = locale.setlocale(locale.LC_ALL)
          try:
              yield locale.setlocale(locale.LC_ALL, name)
          finally:
              locale.setlocale(locale.LC_ALL, old_locale)
docs: Context manager with threading lock for set locale on enter, and set it
      back to original state on exit.
  
      ::
  
          >>> with setlocale("C"):
          ...     ...