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

Most of the readers don't close files properly. (Trac #950) #1027

Closed
sasview-bot opened this issue Mar 30, 2019 · 2 comments
Closed

Most of the readers don't close files properly. (Trac #950) #1027

sasview-bot opened this issue Mar 30, 2019 · 2 comments
Assignees
Labels
Defect Bug or undesirable behaviour Major Big change in the code or important change in behaviour
Milestone

Comments

@sasview-bot
Copy link

sasview-bot commented Mar 30, 2019

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

{
    "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"
}
@sasview-bot sasview-bot added this to the SasView 4.2.0 milestone Mar 30, 2019
@sasview-bot sasview-bot added Defect Bug or undesirable behaviour Incomplete Migration Major Big change in the code or important change in behaviour and removed Incomplete Migration labels Mar 30, 2019
@sasview-bot
Copy link
Author

Trac update at 2017/04/11 12:53:07:

  • krzywon commented:

I'm already working on a refactor of the data loader system and had the same idea of abstracting the readers. I'll take this.

  • krzywon changed owner from "" to "krzywon"
  • krzywon changed status from "new" to "accepted"

@sasview-bot
Copy link
Author

Trac update at 2017/08/22 18:55:20:

In changeset f001bc9:

#!CommitTicketReference repository="sasview" revision="f001bc9e4b9d1ac0d4712117442f0c949334dbc4"
Merge pull request #323 from lewisodriscoll/ticket-876

Refactor File Loaders - fixes #974 #1027 #940 #962 #1005 #1054 #1044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Bug or undesirable behaviour Major Big change in the code or important change in behaviour
Projects
None yet
Development

No branches or pull requests

2 participants