{"action":"created","issue":{"url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/168","labels_url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/168/comments","events_url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/168/events","html_url":"https://github.com/spacetelescope/pyasdf/issues/168","id":99463302,"number":168,"title":"problem using `with` to read a file","user":{"login":"nden","id":1110361,"avatar_url":"https://avatars.githubusercontent.com/u/1110361?v=3","gravatar_id":"","url":"https://api.github.com/users/nden","html_url":"https://github.com/nden","followers_url":"https://api.github.com/users/nden/followers","following_url":"https://api.github.com/users/nden/following{/other_user}","gists_url":"https://api.github.com/users/nden/gists{/gist_id}","starred_url":"https://api.github.com/users/nden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nden/subscriptions","organizations_url":"https://api.github.com/users/nden/orgs","repos_url":"https://api.github.com/users/nden/repos","events_url":"https://api.github.com/users/nden/events{/privacy}","received_events_url":"https://api.github.com/users/nden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-06T15:33:14Z","updated_at":"2015-08-18T19:42:48Z","closed_at":null,"body":"@mdboom Should I not use `with` to open asdf files? Or am I doing something wrong?\r\n\r\n```\r\nar = np.arange(36).reshape((6,6))\r\nf = AsdfFile()\r\nf.tree = {'regions': ar, 'reftype': 'regions'}\r\nf.write_to('test.asdf')\r\n```\r\n\r\n```\r\nwith AsdfFile.open('test.asdf') as f:\r\n    reg=f.tree['regions']\r\nprint reg\r\n<array (unloaded) shape: [6, 6] dtype: int64>\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/comments/132329392","html_url":"https://github.com/spacetelescope/pyasdf/issues/168#issuecomment-132329392","issue_url":"https://api.github.com/repos/spacetelescope/pyasdf/issues/168","id":132329392,"user":{"login":"embray","id":676149,"avatar_url":"https://avatars.githubusercontent.com/u/676149?v=3","gravatar_id":"","url":"https://api.github.com/users/embray","html_url":"https://github.com/embray","followers_url":"https://api.github.com/users/embray/followers","following_url":"https://api.github.com/users/embray/following{/other_user}","gists_url":"https://api.github.com/users/embray/gists{/gist_id}","starred_url":"https://api.github.com/users/embray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embray/subscriptions","organizations_url":"https://api.github.com/users/embray/orgs","repos_url":"https://api.github.com/users/embray/repos","events_url":"https://api.github.com/users/embray/events{/privacy}","received_events_url":"https://api.github.com/users/embray/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T19:42:48Z","updated_at":"2015-08-18T19:42:48Z","body":"I think there should still be more control over this kind of thing.  PyFITS deliberately leaves the mmaps open because it's an implementation detail which most users won't even tend to understand, and not allowing this to work I think discourages use of the `with` statement by users in many cases (for read-only applications it doesn't matter, but there are plenty of write applications where it would be good to use `with`).\r\n\r\nOf course, PyFITS has the opposite problem where users think they've closed the file but they really haven't.  I think both should have some way to control this better (but I lean toward leaning mmaps open except when the user has explicitly requested to close them as well).  "}}