Skip to content

Commit de20bb6

Browse files
paolobarbolinipietroalbini
authored andcommitted
Add a timeout to requests
By default requests never times out, the problems with this are: * The bot won't work after the internet connection comes back. * If the internet connection goes out the only way to stop the bot will be to kill the process.
1 parent a5d0b96 commit de20bb6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

botogram/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def _session(self):
9595
def call(self, method, params=None, files=None, expect=None):
9696
"""Call a method of the API"""
9797
url = self._endpoint + "bot%s/%s" % (self._api_key, method)
98-
response = self._session().get(url, params=params, files=files)
98+
response = self._session().get(url, params=params, files=files,
99+
timeout=10)
99100
content = response.json()
100101

101102
if not content["ok"]:

docs/changelog/0.4.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ Performance improvements
3939
------------------------
4040

4141
* botogram now tries to reuse existing connections to Telegram when possible
42+
43+
Bug fixes
44+
---------
45+
46+
* Fix inability to fetch updates and stop the runner after an internet
47+
connection outage.

0 commit comments

Comments
 (0)