Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #221 (defect)

Opened 3 years ago

Last modified 3 years ago

_cphttptools.serve_file() doesn't close file object

Status: closed (fixed)

Reported by: dowski Assigned to: rdelon
Priority: normal Milestone: 2.1
Component: CherryPy code Keywords:
Cc:

Found this working with StaticFilter. I tried editing a CSS file in my /includes dir (which had static filter running on it) and got a file locking error. StaticFilter calls _cphttptools.serve_file(filename). serve_file() then does the following:

    cherrypy.response.body = open(filename, 'rb')

Since it wouldn't make sense to call cherrypy.response.body.close(), the file is never closed and we have the locking problem I encountered.

I am attaching a patch that replaces the line above with the following:

    bodyfile = open(filename, 'rb')
    cherrypy.response.body = fileGenerator(bodyfile)

That takes care of the body being iterable and closes the file when finished.

Attachments

_cphttptools.serve_file.patch (0.6 kB) - added by dowski on 07/10/05 21:07:58.
patch to _cphttptools

Change History

07/10/05 21:07:58: Modified by dowski

  • attachment _cphttptools.serve_file.patch added.

patch to _cphttptools

07/10/05 23:34:09: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in changeset [446]. Thanks for the patch!

Hosted by WebFaction

Log in as guest/cpguest to create tickets