Question about usage of globals() in execution module
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
is the usage of globals() in execution module allowed ?
usallly when we have multiple state files, we begin with something like this
{% set my_global_dict = salt['my_module.get_my_data']() %}
my_global_dict contains every thing we need to set our states (like what we could have with map.jinja, but using execution module)
if get_my_data require some compute, call it at every sls file will leads to slowdown the exceution of the highstate
so we tried storing our global dict in the __context__ dict
def get_my_data():
"""
"""
if '__mydata__' not in __context__:
_get_my_data()
return __context__['__mydata__']
def _get_my_data():
"""
"""
# ...
# compute my_global_dict here
# ...
__context__['__mydata__'] = my_global_dict
but it seems that __context__ could be destroyed in some cases
we tried then using the globals() dict instead of __context__ and it is ok for our usage
before setting it up i wanted to be sure that we are not doing something in a wrong way
And if it is not, could you please tell me how we can achieve that
thank you !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the execution module and the globals() and __context__ entry points; start by tracing their lifecycle across multiple SLS files and a highstate. Confirm whether either mechanism is supported for caching computed data, then document the supported approach and its limitations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- infrastructure
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100