docstr: `add_file` is thread-safe.
docstr_tok: ["`","add_file","`","is","thread-safe","."]
code: def test_add_file(self):
      """`add_file` is thread-safe."""
      # Call `add_file` from a bunch of threads
      added_files = []
  
      def add_file(index: int) -> None:
          file = UploadedFileRec(
              file_id=f"id_{index}",
              name=f"file_{index}",
              type="type",
              data=bytes(f"{index}", "utf-8"),
          )
  
          self.mgr.add_file("session", file)
          files_from_storage = self.mgr.get_files(
              "session", [file.file_id]
          )
          added_files.extend(files_from_storage)
  
      call_on_threads(add_file, num_threads=self.NUM_THREADS)
  
      # Ensure all our files are present
      for ii in range(self.NUM_THREADS):
          files = self.mgr.get_files("session", [f"id_{ii}"])
          self.assertEqual(1, len(files))
          self.assertEqual(bytes(f"{ii}", "utf-8"), files[0].data)
  
      # Ensure all files have unique IDs
      file_ids = set()
      for file_rec in self.mgr.file_storage["session"].values():
          file_ids.add(file_rec.file_id)
      self.assertEqual(self.NUM_THREADS, len(file_ids))
  
file_path: streamlit/lib/tests/streamlit/runtime/uploaded_file_manager_test.py
imports: import unittest
  from streamlit.runtime.memory_uploaded_file_manager import MemoryUploadedFileManager
  from streamlit.runtime.stats import CacheStat
  from streamlit.runtime.uploaded_file_manager import UploadedFileRec
  from tests.exception_capturing_thread import call_on_threads
label_desc: Use image node_id 2 for calling the UploadedFileManagerThreadingTest obj's underlying member method code with example usage: obj.test_add_file() without return types