'Record the end of a request.'

def record_stop(self, uriset=None, slow_queries=1.0, slow_queries_count=100, debug=False, **kwargs):

    resp = cherrypy.serving.response
    w = appstats['Requests'][threading._get_ident()]
    r = cherrypy.request.rfile.bytes_read
    w['Bytes    Read'] = r
    appstats['Total    Bytes    Read'] += r
    if resp.stream:
        w['Bytes    Written'] = 'chunked'
    else:
        cl = int(resp.headers.get('Content-Length', 0))
        w['Bytes    Written'] = cl
        appstats['Total    Bytes    Written'] += cl
    w['Response    Status'] = (getattr(resp, 'output_status', None) or resp.status)
    w['End    Time'] = time.time()
    p = (w['End    Time'] - w['Start    Time'])
    w['Processing    Time'] = p
    appstats['Total    Time'] += p
    appstats['Current    Requests'] -= 1
    if debug:
        cherrypy.log(('Stats    recorded:    %s' % repr(w)), 'TOOLS.CPSTATS')
    if uriset:
        rs = appstats.setdefault('URI    Set    Tracking', {})
        r = rs.setdefault(uriset, {'Min': None, 'Max': None, 'Count': 0, 'Sum': 0, 'Avg': average_uriset_time})
        if ((r['Min'] is None) or (p < r['Min'])):
            r['Min'] = p
        if ((r['Max'] is None) or (p > r['Max'])):
            r['Max'] = p
        r['Count'] += 1
        r['Sum'] += p
    if (slow_queries and (p > slow_queries)):
        sq = appstats.setdefault('Slow    Queries', [])
        sq.append(w.copy())
        if (len(sq) > slow_queries_count):
            sq.pop(0)
