Adds benchmarking to request handling
This commit is contained in:
parent
4f64b22f4f
commit
0c888687fa
1 changed files with 4 additions and 0 deletions
|
@ -76,6 +76,7 @@ async def process_json(app, body: dict) -> dict:
|
||||||
clean_input_params(params)
|
clean_input_params(params)
|
||||||
logger.debug(f'Received Method {method}, params: {params}')
|
logger.debug(f'Received Method {method}, params: {params}')
|
||||||
try:
|
try:
|
||||||
|
start = time.time()
|
||||||
if asyncio.iscoroutinefunction(METHODS[method]):
|
if asyncio.iscoroutinefunction(METHODS[method]):
|
||||||
result = await METHODS[method](app, params)
|
result = await METHODS[method](app, params)
|
||||||
else:
|
else:
|
||||||
|
@ -87,6 +88,9 @@ async def process_json(app, body: dict) -> dict:
|
||||||
response['error'] = make_error('INVALID_PARAMS', err)
|
response['error'] = make_error('INVALID_PARAMS', err)
|
||||||
else:
|
else:
|
||||||
response['error'] = make_error('INTERNAL', err)
|
response['error'] = make_error('INTERNAL', err)
|
||||||
|
finally:
|
||||||
|
end = time.time()
|
||||||
|
logger.debug(f'Time taken to process {method}: {end - start} secs')
|
||||||
else:
|
else:
|
||||||
response['error'] = make_error('METHOD_NOT_FOUND')
|
response['error'] = make_error('METHOD_NOT_FOUND')
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in a new issue