Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable config to be used as context manager #7363

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eriknw
Copy link
Contributor

@eriknw eriknw commented Mar 22, 2024

Small enhancement to config to allow it to be used with with ...:.

CC @rossbar, weren't you interested in using context managers? For example (and CC @Schefflera-Arboricola):

with nx.config.backends.parallel(n_jobs=8):
    ...

Our config uses a simple stack to handle contexts and is unapologetically global. It does not even attempt to work well in multithreaded code via thread locals or async code via context variables (and trying to support both is non-trivial, so applications should roll their own solutions as necessary). #7345 actually adds a note to the config docs about this:

This is a global configuration. Use with caution when using from multiple threads.

@rossbar rossbar added the Dispatching Related to dispatching and backend support label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dispatching Related to dispatching and backend support
Development

Successfully merging this pull request may close these issues.

None yet

2 participants