count = 0 debug = True def handler(request): cur = conn.cursor() try: cur.execute("SELECT * FROM url_source where id>%s LIMIT 1", (10000 + randint(1000, 5000),)) rs = cur.fetchall() finally: cur.close() cookie = request.get_cookie('testcookie') r = HTTPReponse("""Hello world, %s, cookie: %s, request: %s data: %s Schedule: %s""" % \ (datetime.now(), cookie, request, rs[0], schedule), 'text/plain') r.set_cookie('testcookie', '%s' % time.time()) yield r httpserver = HTTPServer(handler) httpserver.listen(8081) schedule = Scheduler.instance() schedule.new(httpserver.start()) schedule.mainloop()
def main(): httpserver = HTTPServer(handler) httpserver.listen(port) s = Scheduler.instance(debug=False) s.new(httpserver.start()) s.mainloop()