def GET ( self ): global feeder if not feeder.is_alive(): feeder = Process( target=smf.feeder.run, args=( constants.DEFAULT_CONFIG, ) ) feeder.daemon = True feeder.start() session.set_flash = "Feeder Started" else: session.set_flash = "Feeder Already Running" raise web.seeother( '/' )
if False != session.set_flash: session.flash = session.set_flash session.set_flash = False if False != session.set_error_flash: session.error_flash = session.set_error_flash session.set_error_flash = False def feeder_loadhook (): session.feeder = feeder.is_alive() def flash_unloadhook (): session.flash = False session.error_flash = False app.add_processor( web.loadhook( permission_loadhook ) ) app.add_processor( web.loadhook( flash_loadhook ) ) app.add_processor( web.loadhook( feeder_loadhook ) ) app.add_processor( web.unloadhook( flash_unloadhook ) ) ####### Start the Feeder ####### feeder = Process( target=smf.feeder.run, args=( constants.DEFAULT_CONFIG, ) ) feeder.daemon = True feeder.start() ####### Start the Server ####### try: app.run() except Exception, e: feeder.terminate() feeder.join()