Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix returned HTTP error when query runs too long #3320

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nominatim/server/falcon/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Optional, Mapping, cast, Any, List
from pathlib import Path
import datetime as dt
import asyncio

from falcon.asgi import App, Request, Response

Expand Down Expand Up @@ -164,6 +165,8 @@ def get_application(project_dir: Path,
middleware=middleware)
app.add_error_handler(HTTPNominatimError, nominatim_error_handler)
app.add_error_handler(TimeoutError, timeout_error_handler)
# different from TimeoutError in Python <= 3.10
app.add_error_handler(asyncio.TimeoutError, timeout_error_handler)

legacy_urls = api.config.get_bool('SERVE_LEGACY_URLS')
for name, func in api_impl.ROUTES:
Expand Down
4 changes: 3 additions & 1 deletion nominatim/server/starlette/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Any, Optional, Mapping, Callable, cast, Coroutine, Dict, Awaitable
from pathlib import Path
import datetime as dt
import asyncio

from starlette.applications import Starlette
from starlette.routing import Route
Expand Down Expand Up @@ -144,7 +145,8 @@ def get_application(project_dir: Path,
middleware.append(Middleware(FileLoggingMiddleware, file_name=log_file))

exceptions: Dict[Any, Callable[[Request, Exception], Awaitable[Response]]] = {
TimeoutError: timeout_error
TimeoutError: timeout_error,
asyncio.TimeoutError: timeout_error
}

async def _shutdown() -> None:
Expand Down
Loading