You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whilst inspecting the file reading code in sas.sascalc.dataloader.readers I discovered that most of the file readers don't close the file once they've finished with them.
The files should be opened with a context manager:
with open(filename, 'r') as f:
do stuff
A lot of this abstraction could occur in a superclass that all the Readers could inherit. The specific readers being given an open file handle, which the superclass would close. Alternatively it could be done with a decorator.
Relevant files are: abs_reader, anton_paar_saxs_reader, ascii_reader (uses close but it'd be easier with a context manager), cansas_reader, danse_reader, hfir1d_reader, tiff_reader.
{
"status": "closed",
"changetime": "2017-08-22T18:55:20",
"_ts": "2017-08-22 18:55:20.885111+00:00",
"description": "Whilst inspecting the file reading code in sas.sascalc.dataloader.readers I discovered that most of the file readers don't close the file once they've finished with them.\n\nThe files should be opened with a context manager:\n\nwith open(filename, 'r') as f:\n # do stuff\n\nA lot of this abstraction could occur in a superclass that all the Readers could inherit. The specific readers being given an open file handle, which the superclass would close. Alternatively it could be done with a decorator.\n\nRelevant files are: abs_reader, anton_paar_saxs_reader, ascii_reader (uses close but it'd be easier with a context manager), cansas_reader, danse_reader, hfir1d_reader, tiff_reader.",
"reporter": "andyfaff",
"cc": "",
"resolution": "fixed",
"workpackage": "SasView Bug Fixing",
"time": "2017-04-11T04:07:04",
"component": "SasView",
"summary": "Most of the readers don't close files properly.",
"priority": "major",
"keywords": "",
"milestone": "SasView 4.2.0",
"owner": "krzywon",
"type": "defect"
}
The text was updated successfully, but these errors were encountered:
Whilst inspecting the file reading code in sas.sascalc.dataloader.readers I discovered that most of the file readers don't close the file once they've finished with them.
The files should be opened with a context manager:
with open(filename, 'r') as f:
do stuff
A lot of this abstraction could occur in a superclass that all the Readers could inherit. The specific readers being given an open file handle, which the superclass would close. Alternatively it could be done with a decorator.
Relevant files are: abs_reader, anton_paar_saxs_reader, ascii_reader (uses close but it'd be easier with a context manager), cansas_reader, danse_reader, hfir1d_reader, tiff_reader.
Migrated from http://trac.sasview.org/ticket/950
The text was updated successfully, but these errors were encountered: