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

Unclosed file / ResourceWarning #162

Closed
anders-kiaer opened this issue Sep 18, 2020 · 2 comments · Fixed by #163
Closed

Unclosed file / ResourceWarning #162

anders-kiaer opened this issue Sep 18, 2020 · 2 comments · Fixed by #163
Labels
bug Something isn't working

Comments

@anders-kiaer
Copy link
Collaborator

anders-kiaer commented Sep 18, 2020

 WARNING: 	[...]/python3.6/site-packages/fmu/ensemble/realization.py:570: ResourceWarning:

unclosed file <_io.TextIOWrapper name='[...]/realization-7/iter-1/jobs.json' mode='r' encoding='UTF-8'>

from this line

jobsinfo = json.load(open(jsonfilename))

@anders-kiaer anders-kiaer added the bug Something isn't working label Sep 18, 2020
@berland
Copy link
Collaborator

berland commented Sep 18, 2020

These will probably also give similar warnings:

✔ ~/projects/fmu-ensemble [master|…14⚑ 4] 
10:52 $ grep -r "load(" --include "*.py" | grep -v eggs
tests/test_observations.py:    obs2r = Observations(yaml.full_load(obs2.to_yaml()))
tests/test_realization.py:def test_status_load(tmpdir):
tests/test_batch.py:    ymlconfig = yaml.safe_load(yamlstr)
src/fmu/ensemble/realization.py:                jobsinfo = json.load(open(jsonfilename))
src/fmu/ensemble/realization.py:                            metadict = yaml.full_load(open(os.path.join(dirname, cand)))
src/fmu/ensemble/ensemble.py:                manifest_fromyaml = yaml.safe_load(open(manifest))
src/fmu/ensemble/virtualensemble.py:                manifest_fromyaml = yaml.safe_load(open(manifest))
src/fmu/ensemble/observations.py:                self.observations = yaml.full_load(yamlfile)

@anders-kiaer
Copy link
Collaborator Author

I can extend #163 to also fix those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants