Skip to content

Commit 7e7acde

Browse files
committed
set default network_delay to 5 seconds
fixes python-telegram-bot#309
1 parent 792ad62 commit 7e7acde

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

telegram/bot.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,31 +1182,27 @@ def editMessageReplyMarkup(
11821182
return url, data
11831183

11841184
@log
1185-
def getUpdates(self, offset=None, limit=100, timeout=0, network_delay=.2, **kwargs):
1185+
def getUpdates(self, offset=None, limit=100, timeout=0, network_delay=5., **kwargs):
11861186
"""Use this method to receive incoming updates using long polling.
11871187
11881188
Args:
1189-
offset:
1190-
Identifier of the first update to be returned. Must be greater by
1191-
one than the highest among the identifiers of previously received
1192-
updates. By default, updates starting with the earliest unconfirmed
1193-
update are returned. An update is considered confirmed as soon as
1194-
getUpdates is called with an offset higher than its update_id.
1195-
limit:
1196-
Limits the number of updates to be retrieved. Values between 1-100
1197-
are accepted. Defaults to 100.
1198-
timeout:
1199-
Timeout in seconds for long polling. Defaults to 0, i.e. usual
1200-
short polling.
1201-
network_delay:
1202-
Additional timeout in seconds to allow the response from Telegram
1203-
to take some time when using long polling. Defaults to 2, which
1204-
should be enough for most connections. Increase it if it takes very
1205-
long for data to be transmitted from and to the Telegram servers.
1189+
offset (Optional[int]):
1190+
Identifier of the first update to be returned. Must be greater by one than the highest
1191+
among the identifiers of previously received updates. By default, updates starting with
1192+
the earliest unconfirmed update are returned. An update is considered confirmed as soon
1193+
as getUpdates is called with an offset higher than its update_id.
1194+
limit (Optional[int]):
1195+
Limits the number of updates to be retrieved. Values between 1-100 are accepted.
1196+
Defaults to 100.
1197+
timeout (Optional[int]):
1198+
Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling.
1199+
network_delay (Optional[float]):
1200+
Additional timeout in seconds to allow the response from Telegram servers. This should
1201+
cover network latency around the globe, SSL handshake and slowness of the Telegram
1202+
servers (which unfortunately happens a lot recently - 2016-05-28). Defaults to 5.
12061203
12071204
Returns:
1208-
list[:class:`telegram.Update`]: A list of :class:`telegram.Update`
1209-
objects are returned.
1205+
list[:class:`telegram.Update`]
12101206
12111207
Raises:
12121208
:class:`telegram.TelegramError`

telegram/ext/updater.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,25 @@ def _thread_wrapper(self, target, *args, **kwargs):
112112
def start_polling(self,
113113
poll_interval=0.0,
114114
timeout=10,
115-
network_delay=2,
115+
network_delay=5.,
116116
clean=False,
117117
bootstrap_retries=0):
118118
"""
119119
Starts polling updates from Telegram.
120120
121121
Args:
122-
poll_interval (Optional[float]): Time to wait between polling
123-
updates from Telegram in seconds. Default is 0.0
122+
poll_interval (Optional[float]): Time to wait between polling updates from Telegram in
123+
seconds. Default is 0.0
124+
124125
timeout (Optional[float]): Passed to Bot.getUpdates
126+
125127
network_delay (Optional[float]): Passed to Bot.getUpdates
126-
clean (Optional[bool]): Whether to clean any pending updates on
127-
Telegram servers before actually starting to poll. Default is
128-
False.
129-
bootstrap_retries (Optional[int[): Whether the bootstrapping phase
130-
of the `Updater` will retry on failures on the Telegram server.
128+
129+
clean (Optional[bool]): Whether to clean any pending updates on Telegram servers before
130+
actually starting to poll. Default is False.
131+
132+
bootstrap_retries (Optional[int]): Whether the bootstrapping phase of the `Updater`
133+
will retry on failures on the Telegram server.
131134
132135
| < 0 - retry indefinitely
133136
| 0 - no retries (default)

0 commit comments

Comments
 (0)