pysat / pysatNASA

pysat support for NASA Instruments
BSD 3-Clause "New" or "Revised" License
21 stars 6 forks source link

BUG: Added with statement to file open #47

Closed rstoneback closed 3 years ago

rstoneback commented 3 years ago

Review of test logs in pysat v2.3 revealed:

ResourceWarning: Enable tracemalloc to get the object allocation traceback
1733/home/travis/build/pysat/pysat/pysat/instruments/methods/nasa_cdaweb.py:339: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpe4lbgacq/timed/saber/timed_l2av207_saber_201901010209_v01.cdf'>
1734  open(saved_local_fname, 'wb').write(req.content)
1735

I added a with statement to the open command to ensure the file is closed.