code: def spark_session():
      # Spark registers a global signal handler that can cause problems elsewhere
      # in the test suite. In particular, the handler fails if the spark session
      # is stopped (a bug in pyspark).
      prev = signal.getsignal(signal.SIGINT)
      # Create a spark session. Note that we set the timezone to UTC to avoid
      # conversion to local time when reading parquet files.
      spark = (
          pyspark.sql.SparkSession.builder.master("local")
          .appName("Dask Testing")
          .config("spark.sql.session.timeZone", "UTC")
          .getOrCreate()
      )
      yield spark
  
      spark.stop()
      # Make sure we get rid of the signal once we leave stop the session.
      if threading.current_thread() is threading.main_thread():
          signal.signal(signal.SIGINT, prev)
  
file_path: dask/dask/tests/test_spark_compat.py
imports: from __future__ import annotations
  import decimal
  import signal
  import sys
  import threading
  import pytest
  from dask.datasets import timeseries
  import numpy
  import pandas
  from dask.dataframe._compat import PANDAS_GE_150, PANDAS_GE_200
  from dask.dataframe.utils import assert_eq
label_desc: Use image node_id 2 for calling a global function with example usage: spark_session() without return types