Remove some error logs for canceled requests (as the map page tends to do that quite a lot)
This commit is contained in:
parent
0cbf03cd56
commit
e266a4f40a
|
@ -39,9 +39,26 @@ c = app.config
|
||||||
api = Blueprint("api", url_prefix="/api")
|
api = Blueprint("api", url_prefix="/api")
|
||||||
auth = Blueprint("auth", url_prefix="")
|
auth = Blueprint("auth", url_prefix="")
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
TILE_REQUEST_CANCELLED = re.compile(
|
||||||
|
r"Connection lost before response written.*GET /tiles"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class NoConnectionLostFilter(logging.Filter):
|
||||||
|
def filter(record):
|
||||||
|
return not TILE_REQUEST_CANCELLED.match(record.getMessage())
|
||||||
|
|
||||||
|
|
||||||
|
logging.getLogger("sanic.error").addFilter(NoConnectionLostFilter)
|
||||||
|
|
||||||
|
|
||||||
@app.exception(SanicException, BaseException)
|
@app.exception(SanicException, BaseException)
|
||||||
async def _handle_sanic_errors(_request, exception):
|
async def _handle_sanic_errors(_request, exception):
|
||||||
|
if exception is asyncio.CancelledError:
|
||||||
|
return None
|
||||||
|
|
||||||
log.error("Exception in handler: %s", exception, exc_info=True)
|
log.error("Exception in handler: %s", exception, exc_info=True)
|
||||||
return json_response(
|
return json_response(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue