Skip to content

Commit

Permalink
Add timeout - Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-majlis committed Dec 16, 2017
1 parent dbf50ed commit 2d304fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wikipediaapi/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(
user_agent=(
'Wikipedia-API (https://github.com/martin-majlis/Wikipedia-API)'
),
timeout=10.0
):
'''
Language of the API being requested.
Expand All @@ -48,6 +49,7 @@ def __init__(
self.language = language.strip().lower()
self.user_agent = user_agent
self.extract_format = extract_format
self.timeout = timeout

def page(
self,
Expand Down Expand Up @@ -250,7 +252,8 @@ def _query(
r = requests.get(
base_url,
params=params,
headers=headers
headers=headers,
timeout=self.timeout,
)
return r.json()

Expand Down

0 comments on commit 2d304fe

Please sign in to comment.