Skip to content

Commit 73203b6

Browse files
authored
add timeout to requests (#8)
1 parent 5edac3a commit 73203b6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

detectlanguage/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def __init__(self, configuration):
1313
self.configuration = configuration
1414

1515
def get(self, path, payload = {}):
16-
r = requests.get(self.url(path), params=payload, headers = self.headers())
16+
r = requests.get(self.url(path), params=payload, headers = self.headers(), timeout = self.configuration.timeout)
1717
return self.handle_response(r)
1818

1919
def post(self, path, payload):
20-
r = requests.post(self.url(path), json=payload, headers = self.headers())
20+
r = requests.post(self.url(path), json=payload, headers = self.headers(), timeout = self.configuration.timeout)
2121
return self.handle_response(r)
2222

2323
def handle_response(self, r):

detectlanguage/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ class Configuration:
66
host = 'ws.detectlanguage.com'
77
user_agent = 'Detect Language API Python Client ' + detectlanguage.__version__
88
secure = False
9+
timeout = 5

0 commit comments

Comments
 (0)