# Buggy code
def start_polling(
    self,
    poll_interval=0.0,
    timeout=10,
    network_delay=2,
    clean=False,
    bootstrap_retries=0,
):
    """
    Starts polling updates from Telegram.

    Args:
        poll_interval (Optional[float]): Time to wait between polling
            updates from Telegram in seconds. Default is 0.0
        timeout (Optional[float]): Passed to Bot.getUpdates
        network_delay (Optional[float]): Passed to Bot.getUpdates
        clean (Optional[bool]): Whether to clean any pending updates on
            Telegram servers before actually starting to poll. Default is
            False.
        bootstrap_retries (Optional[int[): Whether the bootstrapping phase
            of the `Updater` will retry on failures on the Telegram server.

            |   < 0 - retry indefinitely
            |   0 - no retries (default)
            |   > 0 - retry up to X times

    Returns:
        Queue: The update queue that can be filled from the main thread

    """
    with self.__lock:
        if not self.running:
            self.running = True

            # Create & start threads
            self._init_thread(self.dispatcher.start, "dispatcher")
            self._init_thread(
                self._start_polling,
                "updater",
                poll_interval,
                timeout,
                network_delay,
                bootstrap_retries,
                clean,
            )

            # Return the update queue so the main thread can insert updates
            return self.update_queue


# Traceback (NetworkError)
Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
import telegram
bot = telegram.Bot(token='123123:My_token')
print(bot.getMe())
{'username': u'My_bot', 'first_name': u'Flexget', 'last_name': '', 'type': '', 'id': 123123}
updates = bot.getUpdates()

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
updates = bot.getUpdates()
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 109, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 1215, in getUpdates
result = request.post(url, data, timeout=urlopen_timeout)
File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 83, in decorator
raise NetworkError('URLError: {0}'.format(error.reason))
NetworkError: URLError: [Errno 101] Network is unreachable
chat_id = bot.getUpdates()[-1].message.chat_id

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
chat_id = bot.getUpdates()[-1].message.chat_id
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 109, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 1215, in getUpdates
result = request.post(url, data, timeout=urlopen_timeout)
File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 83, in decorator
raise NetworkError('URLError: {0}'.format(error.reason))
NetworkError: URLError: [Errno 101] Network is unreachable


# Fixed code
def start_polling(
    self,
    poll_interval=0.0,
    timeout=10,
    network_delay=5.0,
    clean=False,
    bootstrap_retries=0,
):
    """
    Starts polling updates from Telegram.

    Args:
        poll_interval (Optional[float]): Time to wait between polling updates from Telegram in
        seconds. Default is 0.0

        timeout (Optional[float]): Passed to Bot.getUpdates

        network_delay (Optional[float]): Passed to Bot.getUpdates

        clean (Optional[bool]): Whether to clean any pending updates on Telegram servers before
          actually starting to poll. Default is False.

        bootstrap_retries (Optional[int]): Whether the bootstrapping phase of the `Updater`
          will retry on failures on the Telegram server.

            |   < 0 - retry indefinitely
            |   0 - no retries (default)
            |   > 0 - retry up to X times

    Returns:
        Queue: The update queue that can be filled from the main thread

    """
    with self.__lock:
        if not self.running:
            self.running = True

            # Create & start threads
            self._init_thread(self.dispatcher.start, "dispatcher")
            self._init_thread(
                self._start_polling,
                "updater",
                poll_interval,
                timeout,
                network_delay,
                bootstrap_retries,
                clean,
            )

            # Return the update queue so the main thread can insert updates
            return self.update_queue