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

    configure_views(app)
    configure_handlers(app)

    return app
Beispiel #2
0
def create_app():
    app = Worker(Box)
    app.job_timeout = 60
    app.stop_timeout = 10

    configure_views(app)
    configure_handlers(app)

    return app
Beispiel #3
0
handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


logger2 = logging.getLogger('netkit')
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

app = Worker(Box)


def monitor_profile(func):
    import cProfile
    import functools
    @functools.wraps(func)
    def func_wrapper(request, *args, **kwargs):
        def tmpfunc():
            return func(request, *args, **kwargs)
        # 直接用run是不行的
        cProfile.runctx("tmpfunc()", globals(), locals(), "%s.stat" % request.endpoint)
    return func_wrapper

@app.route(2)
@monitor_profile
Beispiel #4
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)
Beispiel #5
0
# -*- coding: utf-8 -*-

from maple import Worker
from netkit.box import Box
from xstat import MapleStat
import user

app = Worker(Box)
app.register_blueprint(user.bp)

maple_stat = MapleStat(app, dict(
    XSTAT_TITLE='dante.test',
    XSTAT_HOST='127.0.0.1',
))


@app.route(1)
def register(request):
    request.write_to_client(dict(
        ret=0
    ))

if __name__ == '__main__':
    app.run('127.0.0.1', 28000, debug=True)
Beispiel #6
0
handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


logger2 = logging.getLogger('netkit')
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

app = Worker(Box)


@app.before_request
def bind_real_objects(request):
    """
    绑定真实对象
    :param request:
    :return:
    """
    from maple_proxy import real_objects, G
    real_objects['g'] = G()
    real_objects['request'] = request


@app.route(2)