MCPcopy
hub / github.com/dask/dask / ensure_safe_environment_variables

Function ensure_safe_environment_variables

dask/bytes/tests/test_s3.py:59–70  ·  view source on GitHub ↗

Get a context manager to safely set environment variables All changes will be undone on close, hence environment variables set within this contextmanager will neither persist nor change global state.

()

Source from the content-addressed store, hash-verified

57
58@contextmanager
59def ensure_safe_environment_variables():
60 """
61 Get a context manager to safely set environment variables
62 All changes will be undone on close, hence environment variables set
63 within this contextmanager will neither persist nor change global state.
64 """
65 saved_environ = dict(os.environ)
66 try:
67 yield
68 finally:
69 os.environ.clear()
70 os.environ.update(saved_environ)
71
72
73@pytest.fixture

Callers 1

s3_baseFunction · 0.85

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…