def save_df_to_shared_memory(df: pd.DataFrame, shms: List) -> c.SharedMemoryDataframeInfo:
  """
  Intended to be called before beginning multiprocessing: saves the df to shared memory
  and returns the info needed to access it, as well as appends it to the list of shared memory objects
  so it's not garbage collected and can be closed later.
  """
  with io.BytesIO() as buf:
    df.to_parquet(buf, compression="gzip", engine="pyarrow")
    size = len(buf.getvalue())
    shm = shared_memory.SharedMemory(create=True, size=size)
    shm.buf[:size] = buf.getvalue()
  shms.append(shm)  # save the shared memory object so we can close it later
  return c.SharedMemoryDataframeInfo(
    sharedMemoryName=shm.name,
    dataSize=size,
  )

  Intended to be called before beginning multiprocessing: saves the df to shared memory
  and returns the info needed to access it, as well as appends it to the list of shared memory objects
  so it's not garbage collected and can be closed later.
  
sourcecode/scoring/run_scoring.py