Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Cherrypy as production wsgi server

Date: Fri, 9 Nov 2012 14:59:37 -0800 (PST)
From: Jeffrey Melloy <jmel...@gmail.com>
To: cherrypy-users@googlegroups.com
Message-Id: <b7d74c4c-966d-494c-ba93-f8c50adfda2f@googlegroups.com>
Subject: Cherrypy as production wsgi server
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_895_6633755.1352501977424"

------=_Part_895_6633755.1352501977424
Content-Type: multipart/alternative; 
	boundary="----=_Part_896_25698283.1352501977424"

------=_Part_896_25698283.1352501977424
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

I'm running Cherrypy as the wsgi server in front of a flask app. How do I 
start getting statistics about increasing the threading count?  It serves a 
lot of images that are called simultaneously from a dashboard.

from cherrypy import wsgiserver, log, _cplogging
from test_qd_web_service import app

import logging
import logging.handlers
import sys

from paste.translogger import TransLogger
from repoze.profile.profiler import AccumulatingProfileMiddleware


def run():

    logger = logging.getLogger("accesslog")
    acc = logging.handlers.TimedRotatingFileHandler("test.access.log", 
when="midnight", backupCount = 7)
    logger.addHandler(acc)
    
    wsgi_app = TransLogger(app, logger_name="accesslog", 
setup_console_handler=False)

    profiled_app = AccumulatingProfileMiddleware(
        wsgi_app,
        log_filename='ws.profile',
        discard_first_request=True,
        flush_at_shutdown=True,
        path='/_profile'
        )

    d = wsgiserver.WSGIPathInfoDispatcher({'/': wsgi_app})
    
    server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 5050), wsgi_app, 
numthreads=25)
    

    try:    
        server.start()
    except KeyboardInterrupt:
        server.stop()
                
if __name__ == '__main__':
    run()


------=_Part_896_25698283.1352501977424
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

I'm running Cherrypy as the wsgi server in front of a flask app. How do I s=
tart getting statistics about increasing the threading count? &nbsp;It serv=
es a lot of images that are called simultaneously from a dashboard.<div><br=
></div><div><div>from cherrypy import wsgiserver, log, _cplogging</div><div=
>from test_qd_web_service import app</div><div><br></div><div>import loggin=
g</div><div>import logging.handlers</div><div>import sys</div><div><br></di=
v><div>from paste.translogger import TransLogger</div><div>from repoze.prof=
ile.profiler import AccumulatingProfileMiddleware</div><div><br></div><div>=
<br></div><div>def run():</div><div><br></div><div>&nbsp; &nbsp; logger =3D=
 logging.getLogger("accesslog")<br></div><div>&nbsp; &nbsp; acc =3D logging=
.handlers.TimedRotatingFileHandler("test.access.log", when=3D"midnight", ba=
ckupCount =3D 7)</div><div>&nbsp; &nbsp; logger.addHandler(acc)</div><div>&=
nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; wsgi_app =3D TransLogger(app, lo=
gger_name=3D"accesslog", setup_console_handler=3DFalse)</div><div><br></div=
><div>&nbsp; &nbsp; profiled_app =3D AccumulatingProfileMiddleware(</div><d=
iv>&nbsp; &nbsp; &nbsp; &nbsp; wsgi_app,</div><div>&nbsp; &nbsp; &nbsp; &nb=
sp; log_filename=3D'ws.profile',</div><div>&nbsp; &nbsp; &nbsp; &nbsp; disc=
ard_first_request=3DTrue,<br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; flush_a=
t_shutdown=3DTrue,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; path=3D'/_profile'=
</div><div>&nbsp; &nbsp; &nbsp; &nbsp; )</div><div><br></div><div>&nbsp; &n=
bsp; d =3D wsgiserver.WSGIPathInfoDispatcher({'/': wsgi_app})</div><div>&nb=
sp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; server =3D wsgiserver.CherryPyWSGI=
Server(('0.0.0.0', 5050), wsgi_app, numthreads=3D25)</div><div>&nbsp; &nbsp=
;&nbsp;</div><div><br></div><div>&nbsp; &nbsp; try: &nbsp; &nbsp;</div><div=
>&nbsp; &nbsp; &nbsp; &nbsp; server.start()</div><div>&nbsp; &nbsp; except =
KeyboardInterrupt:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; server.stop()</div=
><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><d=
iv>if __name__ =3D=3D '__main__':</div><div>&nbsp; &nbsp; run()</div></div>=
<div><br></div>
------=_Part_896_25698283.1352501977424--

------=_Part_895_6633755.1352501977424--