question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cherrypy.lib.static.serve_file + sessions == apparent memory leak

See original GitHub issue

Originally reported by: Eric Atkin (Bitbucket: ericatkin, GitHub: ericatkin)


Hi, I’m running into a problem with serving large files with cherrypy.lib.static.serve_file and sessions turned on that causes cherrypy’s process to quickly use all system memory. I’ve included a sample program that demonstrates the issue below. In my case, test.ogg is a ~200MB file. If I turn off sessions, the problem goes away, but I need sessions in my webapp 😦 I’ve dug in to the cherrypy sources for a while, but got lost. Please help. I’m happy to provide more detail or testing if needed.

Many thanks, Eric Atkin

#!/usr/bin/python

import cherrypy

class Root:
    @cherrypy.expose
    def default(self, *args, **kwargs):
        return '''
<html>
    <body>
        <audio controls="controls">
            <source src="/get" type="audio/ogg" /> 
            Sorry, your browser doesn"t support HTML5 audio tags.
        </audio>
    </body>
</html>
'''

    @cherrypy.expose
    def get(self):
        return(cherrypy.lib.static.serve_file('/tmp/test.ogg', content_type='audio/ogg', disposition='attachment', name='test.ogg'))

if __name__ == '__main__':
    cherrypy.quickstart(Root(), config={
        'global': {
            'server.socket_host': '0.0.0.0',
        },
        '/': {
            'tools.sessions.on': True,
        },
    })

Issue Analytics

  • State:open
  • Created 11 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
ghostcommented, Apr 30, 2016

Original comment by Sylvain Hellegouarch (Bitbucket: Lawouach, GitHub: Lawouach):


Though there is still a bug probably, I think this can be workaround by disabling the sessions on the static section:

#!

[/get]
tools.session.on: False
0reactions
bsimjoocommented, Mar 8, 2021

Hi, I have a similar problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apparent memory leak running CherrypPy app - Google Groups
I seem to have a memory leak running my CherryPy 3 app under mod_wsgi 1.3. I'm asking here first because the symptoms I'm...
Read more >
cherrypy.lib.sessions module
Session implementation for CherryPy. ... This sets the session to be stored in files in the directory /home/site/sessions, and the session timeout to...
Read more >
CherryPy Documentation - Read the Docs
By default, CherryPy will save sessions in the process's memory. It supports more persistent backends as well.
Read more >
How to debug memory leak in python with cherrypy and pytorch
It seems your model loads every time when inference calls (or during instantiating server). Sometimes model loading is memory and time ...
Read more >
close a screen session linux Code Example - Code Grepper
kill all screen sessions linux ... First, find the session you want to quit. 2. screen -ls ... how to check which process...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found