Closed nneveu closed 3 years ago
When running distgen within a unit test, I get this warning:
../Users/nneveu/github/distgen/distgen/generator.py:58: ResourceWarning: unclosed file <_io.TextIOWrapper name='../slac/paper_test/tdist.yaml' mode='r' encoding='UTF-8'> input = yaml.safe_load(open(input))
I know this is just a warning, but may be worth closing the file to be safe? Here's the specific code triggering the warning:
dist = Generator(input=self.distgen_file)#, verbose=True) dist.input['r_dist']['max_r']['value'] = radius #mm based on scaling in call script dist.run() particles = dist.particles particles.write_opal('opal_emitted.txt', dist_type= 'emitted')
Thank you for pointing his out. All open statements are now use the 'with' keyword, which should handle file closing.
When running distgen within a unit test, I get this warning:
../Users/nneveu/github/distgen/distgen/generator.py:58: ResourceWarning: unclosed file <_io.TextIOWrapper name='../slac/paper_test/tdist.yaml' mode='r' encoding='UTF-8'> input = yaml.safe_load(open(input))
I know this is just a warning, but may be worth closing the file to be safe? Here's the specific code triggering the warning: