Example #1
0
def create_app():
    app = Worker(Box)
    app.job_timeout = 60
    app.stop_timeout = 10

    configure_views(app)
    configure_handlers(app)

    return app
Example #2
0
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

logger2 = logging.getLogger('maple_timer')
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger2.addHandler(handler)
logger2.setLevel(logging.DEBUG)

from maple import Worker
from netkit.box import Box
from maple_timer import MapleTimer

app = Worker(Box)

timer = MapleTimer(app, dict(interval=15))


@app.route(1)
def reg(request):
    time.sleep(0.1)
    request.write_to_client(dict(ret=0, ))


@app.route(2)
def login(request):
    # logger.error("login: %s", request.gw_box)
    uid = request.box.get_json()["uid"]
    request.login_client(uid)