SparkContext.
setLocalProperty
Set a local property that affects jobs submitted from this thread, such as the Spark fair scheduler pool.
Notes
If you run jobs in parallel, use pyspark.InheritableThread for thread local inheritance.
pyspark.InheritableThread