Yipee, my code got posted into CherryPy:
import cherrypy
import MySQLdb
from DBUtils.PersistentDB import PersistentDB
class HomePage:
@cherrypy.expose
def index(self):
sql = "select max(whatever) from bigtable;" #long running query
c = persDb.connection().cursor()
c.execute(sql)
res = c.fetchone()
c.close()
return ' '.join( ['<html>', repr(res), '</html>'] )
cherrypy.tree.mount(HomePage())
if __name__ == '__main__':
persDb=PersistentDB(MySQLdb, 10000, host='localhost', db='db', passwd='****')
cherrypy.config.update({'server.thread_pool': 10})
cherrypy.server.quickstart()
cherrypy.engine.start()
No comments:
Post a Comment