[CherryPy] #1092: fileopbjects appear not to be explicitly closed

3 views
Skip to first unread message

CherryPy

unread,
Sep 1, 2011, 12:58:27 PM9/1/11
to cherrypy...@googlegroups.com
#1092: fileopbjects appear not to be explicitly closed
-----------------------------------+----------------------------------------
Reporter: kris...@ccpgames.com | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone: 3.2
Component: CherryPy code | Keywords:
-----------------------------------+----------------------------------------
methods such as serve_fileobj() return a generator from a file-like
object. These methods, however, do not appear to ensure that this file
object is closed when it has been exhausted. It is not considered good
practice to have to rely on reference counting to do that for you, and may
be impossible for custom-made file objects.

It would be good to have these generators call close() when the file is
exhausted. Of course, the generators themselves have no "close" semantics
and so may be be left hanging if an exception occurs. This might be
considered a flaw in WSGI.

--
Ticket URL: <http://www.cherrypy.org/ticket/1092>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework

CherryPy

unread,
Sep 2, 2011, 6:51:59 AM9/2/11
to cherrypy...@googlegroups.com
#1092: fileopbjects appear not to be explicitly closed
-----------------------------------+----------------------------------------
Reporter: kris...@ccpgames.com | Owner: fumanchu
Type: defect | Status: new
Priority: normal | Milestone: 3.2
Component: CherryPy code | Resolution:
Keywords: |
-----------------------------------+----------------------------------------
Comment (by guest):

Correction: generators do have close semantics. So, these generators
really should close the file object on exit, or when receiving the
GeneratorExit exception, which could most easily be done with a try-
finally
Reply all
Reply to author
Forward
0 new messages