Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
settings: add PJ_API_TIMEOUT (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-dupre authored Mar 19, 2021
1 parent fa1abfe commit 8455e6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions idunn/datasources/pages_jaunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@ class ApiPjSource(PjSource):
PJ_RESULT_MAX_SIZE = 30
PJ_INFO_API_URL = "https://api.pagesjaunes.fr/v1/pros"
PJ_FIND_API_URL = "https://api.pagesjaunes.fr/v1/pros/search"
PJ_API_TIMEOUT = float(settings.get("PJ_API_TIMEOUT"))

def __init__(self):
super().__init__()
self.session = PjAuthSession()
self.session = PjAuthSession(refresh_timeout=self.PJ_API_TIMEOUT)

@staticmethod
def format_where(bbox):
left, bot, right, top = bbox
return f"gZ{left},{top},{right},{bot}"

def get_from_params(self, url, params=None) -> PjApiPOI:
res = self.session.get(url, params=params)
res = self.session.get(url, params=params, timeout=self.PJ_API_TIMEOUT)
res.raise_for_status()
return res.json()

Expand Down
3 changes: 2 additions & 1 deletion idunn/utils/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ PJ_ES_QUERY_TEMPLATE: "pagesjaunes_query"
# Pages jaunes
PJ_API_ID:
PJ_API_SECRET:
PJ_API_TIMEOUT: 4 # seconds

# OSM
OSM_CONTRIBUTION_HASHTAGS: "QwantMaps" # separated by ",". Used in osm.org/edit URL.
Expand Down Expand Up @@ -114,7 +115,7 @@ CORS_ALLOW_HEADERS: "*"
DIRECTIONS_RL_MAX_REQUESTS: 30 # per client
DIRECTIONS_RL_EXPIRE: 60 # seconds
DIRECTIONS_TIMEOUT: 8 # seconds
DIRECTIONS_CLIENT_CACHE: 60 # seconds
DIRECTIONS_CLIENT_CACHE: 60 # seconds
QWANT_DIRECTIONS_API_BASE_URL:
MAPBOX_DIRECTIONS_API_BASE_URL: "https://api.mapbox.com/directions/v5/mapbox"
MAPBOX_DIRECTIONS_ACCESS_TOKEN:
Expand Down

0 comments on commit 8455e6d

Please sign in to comment.