예제 #1
0
async def test_resolve_redirects_for_titles(redis_client):
    monitoring = Monitoring(redis_client)

    await monitoring.log_request(10, 5.4)
    await monitoring.log_request(10, 5.3)
    await monitoring.log_request(10, 5.2)

    rates = await monitoring.get_rates()

    avg_time = rates[2]['processing_time_per_query']
    assert avg_time > 0.52 and avg_time < 0.54
예제 #2
0
import bottle
import json
import time

from bottle import route, run, request, default_app, template, HTTPError, abort, HTTPResponse
from docopt import docopt
from wdreconcile.engine import ReconcileEngine
from wdreconcile.suggest import SuggestEngine
from wdreconcile.monitoring import Monitoring

from config import *

reconcile = ReconcileEngine(redis_client)
suggest = SuggestEngine(redis_client)
monitoring = Monitoring(redis_client)


def jsonp(view):
    def wrapped(*posargs, **kwargs):
        args = {}
        # if we access the args via get(),
        # we can get encoding errors...
        for k in request.forms:
            args[k] = getattr(request.forms, k)
        for k in request.query:
            args[k] = getattr(request.query, k)
        callback = args.get('callback')
        status_code = 200
        try:
            result = view(args, *posargs, **kwargs)
        except (KeyError) as e:  #ValueError, AttributeError, KeyError) as e:
예제 #3
0
async def request_context():
    g.reconcile = ReconcileEngine(app.redis_client, app.http_session)
    g.suggest = SuggestEngine(app.redis_client, app.http_session)
    g.monitoring = Monitoring(app.redis_client)