# Examples from pyvista.enable_smp_tools
# ======================================

# Enable the wheel-supported `stdthread` backend for the rest of the
# process.
import pyvista as pv
pv.enable_smp_tools()

# Configure the backend before running a contour filter.
from pyvista import examples
pv.enable_smp_tools(n_threads=8)
grid = examples.download_fea_bracket()
_ = grid.contour(5, scalars='Equivalent Stress')

# Scope the backend change to a `with` block. The previous backend and
# thread count are restored on exit, even if an exception is raised.
with pv.enable_smp_tools(n_threads=8):
    _ = grid.contour(5, scalars='Equivalent Stress')

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
