We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bot stopps working after reconnect of system
This error appears after some time of running. Because of some reason my wifi reconnects after some time and after this the bot dont get back to work. Any ideas to prevent this? I have to restart the bot every time this happens.

```
Exception in thread updater:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "C:\Python27\lib\threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "C:\Python27\lib\site-packages\telegram\ext\updater.py", line 146, in _thread_wrapper
    target(*args, **kwargs)
  File "C:\Python27\lib\site-packages\telegram\ext\updater.py", line 223, in _start_polling
    network_delay=network_delay)
  File "C:\Python27\lib\site-packages\telegram\bot.py", line 128, in decorator
    result = func(self, *args, **kwargs)
  File "C:\Python27\lib\site-packages\telegram\bot.py", line 796, in getUpdates
    result = request.post(url, data, network_delay=network_delay)
  File "C:\Python27\lib\site-packages\telegram\utils\request.py", line 77, in decorator
    return func(*args, **kwargs)
  File "C:\Python27\lib\site-packages\telegram\utils\request.py", line 173, in post
    result = urlopen(request, **urlopen_kwargs).read()
  File "C:\Python27\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "C:\Python27\lib\urllib2.py", line 1200, in do_open
    r = h.getresponse(buffering=True)
  File "C:\Python27\lib\httplib.py", line 1136, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\Python27\lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
  File "C:\Python27\lib\ssl.py", line 734, in recv
    return self.read(buflen)
  File "C:\Python27\lib\ssl.py", line 621, in read
    v = self._sslobj.read(len or 1024)
error: [Errno 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `telegram/utils/request.py`
Content:
```
1 #!/usr/bin/env python
2 # pylint: disable=no-name-in-module,unused-import
3 #
4 # A library that provides a Python interface to the Telegram Bot API
5 # Copyright (C) 2015-2016
6 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Lesser Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU Lesser Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser Public License
19 # along with this program.  If not, see [http://www.gnu.org/licenses/].
20 
21 """This module contains methods to make POST and GET requests"""
22 
23 import functools
24 import json
25 import socket
26 from ssl import SSLError
27 
28 try:
29     # python2
30     from httplib import HTTPException
31 except ImportError:
32     # python3
33     from http.client import HTTPException
34 
35 try:
36     # python3
37     from urllib.request import urlopen, urlretrieve, Request
38     from urllib.error import HTTPError, URLError
39 except ImportError:
40     # python2
41     from urllib import urlretrieve
42     from urllib2 import urlopen, Request, URLError
43     from urllib2 import HTTPError
44 
45 from telegram import (InputFile, TelegramError)
46 from telegram.error import Unauthorized, NetworkError, TimedOut
47 
48 
49 def _parse(json_data):
50     """Try and parse the JSON returned from Telegram and return an empty
51     dictionary if there is any error.
52 
53     Args:
54       url:
55         urllib.urlopen object
56 
57     Returns:
58       A JSON parsed as Python dict with results.
59     """
60     decoded_s = json_data.decode('utf-8')
61     try:
62         data = json.loads(decoded_s)
63     except ValueError:
64         raise TelegramError('Invalid server response')
65 
66     if not data.get('ok') and data.get('description'):
67         return data['description']
68 
69     return data['result']
70 
71 
72 def _try_except_req(func):
73     """Decorator for requests to handle known exceptions"""
74     @functools.wraps(func)
75     def decorator(*args, **kwargs):
76         try:
77             return func(*args, **kwargs)
78 
79         except HTTPError as error:
80             # `HTTPError` inherits from `URLError` so `HTTPError` handling must
81             # come first.
82             errcode = error.getcode()
83 
84             if errcode in (401, 403):
85                 raise Unauthorized()
86             elif errcode == 502:
87                 raise NetworkError('Bad Gateway')
88 
89             try:
90                 message = _parse(error.read())
91             except ValueError:
92                 message = 'Unknown HTTPError {0}'.format(error.getcode())
93 
94             raise NetworkError('{0} ({1})'.format(message, errcode))
95 
96         except URLError as error:
97             raise NetworkError('URLError: {0}'.format(error.reason))
98 
99         except (SSLError, socket.timeout) as error:
100             err_s = str(error)
101             if 'operation timed out' in err_s:
102                 raise TimedOut()
103 
104             raise NetworkError(err_s)
105 
106         except HTTPException as error:
107             raise NetworkError('HTTPException: {0!r}'.format(error))
108 
109     return decorator
110 
111 
112 @_try_except_req
113 def get(url):
114     """Request an URL.
115     Args:
116       url:
117         The web location we want to retrieve.
118 
119     Returns:
120       A JSON object.
121     """
122     result = urlopen(url).read()
123 
124     return _parse(result)
125 
126 
127 @_try_except_req
128 def post(url,
129          data,
130          timeout=None,
131          network_delay=2.):
132     """Request an URL.
133     Args:
134       url:
135         The web location we want to retrieve.
136       data:
137         A dict of (str, unicode) key/value pairs.
138       timeout:
139         float. If this value is specified, use it as the definitive timeout (in
140         seconds) for urlopen() operations. [Optional]
141       network_delay:
142         float. If using the timeout specified in `data` (which is a timeout for
143         the Telegram servers operation), then `network_delay` as an extra delay
144         (in seconds) to compensate for network latency.
145         default: 2 [Optional]
146 
147     Notes:
148       If neither `timeout` nor `data['timeout']` is specified. The underlying
149       defaults are used.
150 
151     Returns:
152       A JSON object.
153 
154     """
155     urlopen_kwargs = {}
156 
157     if timeout is not None:
158         urlopen_kwargs['timeout'] = timeout
159     elif 'timeout' in data:
160         urlopen_kwargs['timeout'] = data['timeout'] + network_delay
161 
162     if InputFile.is_inputfile(data):
163         data = InputFile(data)
164         request = Request(url,
165                           data=data.to_form(),
166                           headers=data.headers)
167     else:
168         data = json.dumps(data)
169         request = Request(url,
170                           data=data.encode(),
171                           headers={'Content-Type': 'application/json'})
172 
173     result = urlopen(request, **urlopen_kwargs).read()
174     return _parse(result)
175 
176 
177 @_try_except_req
178 def download(url,
179              filename):
180     """Download a file by its URL.
181     Args:
182       url:
183         The web location we want to retrieve.
184 
185       filename:
186         The filename wihtin the path to download the file.
187     """
188 
189     urlretrieve(url, filename)
190
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/telegram/utils/request.py b/telegram/utils/request.py
--- a/telegram/utils/request.py
+++ b/telegram/utils/request.py
@@ -106,6 +106,9 @@
         except HTTPException as error:
             raise NetworkError('HTTPException: {0!r}'.format(error))
 
+        except socket.error as error:
+            raise NetworkError('socket.error: {0!r}'.format(error))
+
     return decorator

{"golden_diff": "diff --git a/telegram/utils/request.py b/telegram/utils/request.py\n--- a/telegram/utils/request.py\n+++ b/telegram/utils/request.py\n@@ -106,6 +106,9 @@\n         except HTTPException as error:\n             raise NetworkError('HTTPException: {0!r}'.format(error))\n \n+        except socket.error as error:\n+            raise NetworkError('socket.error: {0!r}'.format(error))\n+\n     return decorator\n", "issue": "Bot stopps working after reconnect of system\nThis error appears after some time of running. Because of some reason my wifi reconnects after some time and after this the bot dont get back to work. Any ideas to prevent this? I have to restart the bot every time this happens.\n\n```\nException in thread updater:\nTraceback (most recent call last):\n  File \"C:\\Python27\\lib\\threading.py\", line 801, in __bootstrap_inner\n    self.run()\n  File \"C:\\Python27\\lib\\threading.py\", line 754, in run\n    self.__target(*self.__args, **self.__kwargs)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\ext\\updater.py\", line 146, in _thread_wrapper\n    target(*args, **kwargs)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\ext\\updater.py\", line 223, in _start_polling\n    network_delay=network_delay)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\bot.py\", line 128, in decorator\n    result = func(self, *args, **kwargs)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\bot.py\", line 796, in getUpdates\n    result = request.post(url, data, network_delay=network_delay)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\utils\\request.py\", line 77, in decorator\n    return func(*args, **kwargs)\n  File \"C:\\Python27\\lib\\site-packages\\telegram\\utils\\request.py\", line 173, in post\n    result = urlopen(request, **urlopen_kwargs).read()\n  File \"C:\\Python27\\lib\\urllib2.py\", line 154, in urlopen\n    return opener.open(url, data, timeout)\n  File \"C:\\Python27\\lib\\urllib2.py\", line 431, in open\n    response = self._open(req, data)\n  File \"C:\\Python27\\lib\\urllib2.py\", line 449, in _open\n    '_open', req)\n  File \"C:\\Python27\\lib\\urllib2.py\", line 409, in _call_chain\n    result = func(*args)\n  File \"C:\\Python27\\lib\\urllib2.py\", line 1240, in https_open\n    context=self._context)\n  File \"C:\\Python27\\lib\\urllib2.py\", line 1200, in do_open\n    r = h.getresponse(buffering=True)\n  File \"C:\\Python27\\lib\\httplib.py\", line 1136, in getresponse\n    response.begin()\n  File \"C:\\Python27\\lib\\httplib.py\", line 453, in begin\n    version, status, reason = self._read_status()\n  File \"C:\\Python27\\lib\\httplib.py\", line 409, in _read_status\n    line = self.fp.readline(_MAXLINE + 1)\n  File \"C:\\Python27\\lib\\socket.py\", line 480, in readline\n    data = self._sock.recv(self._rbufsize)\n  File \"C:\\Python27\\lib\\ssl.py\", line 734, in recv\n    return self.read(buflen)\n  File \"C:\\Python27\\lib\\ssl.py\", line 621, in read\n    v = self._sslobj.read(len or 1024)\nerror: [Errno 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen\n```\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# pylint: disable=no-name-in-module,unused-import\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2016\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\n\"\"\"This module contains methods to make POST and GET requests\"\"\"\n\nimport functools\nimport json\nimport socket\nfrom ssl import SSLError\n\ntry:\n    # python2\n    from httplib import HTTPException\nexcept ImportError:\n    # python3\n    from http.client import HTTPException\n\ntry:\n    # python3\n    from urllib.request import urlopen, urlretrieve, Request\n    from urllib.error import HTTPError, URLError\nexcept ImportError:\n    # python2\n    from urllib import urlretrieve\n    from urllib2 import urlopen, Request, URLError\n    from urllib2 import HTTPError\n\nfrom telegram import (InputFile, TelegramError)\nfrom telegram.error import Unauthorized, NetworkError, TimedOut\n\n\ndef _parse(json_data):\n    \"\"\"Try and parse the JSON returned from Telegram and return an empty\n    dictionary if there is any error.\n\n    Args:\n      url:\n        urllib.urlopen object\n\n    Returns:\n      A JSON parsed as Python dict with results.\n    \"\"\"\n    decoded_s = json_data.decode('utf-8')\n    try:\n        data = json.loads(decoded_s)\n    except ValueError:\n        raise TelegramError('Invalid server response')\n\n    if not data.get('ok') and data.get('description'):\n        return data['description']\n\n    return data['result']\n\n\ndef _try_except_req(func):\n    \"\"\"Decorator for requests to handle known exceptions\"\"\"\n    @functools.wraps(func)\n    def decorator(*args, **kwargs):\n        try:\n            return func(*args, **kwargs)\n\n        except HTTPError as error:\n            # `HTTPError` inherits from `URLError` so `HTTPError` handling must\n            # come first.\n            errcode = error.getcode()\n\n            if errcode in (401, 403):\n                raise Unauthorized()\n            elif errcode == 502:\n                raise NetworkError('Bad Gateway')\n\n            try:\n                message = _parse(error.read())\n            except ValueError:\n                message = 'Unknown HTTPError {0}'.format(error.getcode())\n\n            raise NetworkError('{0} ({1})'.format(message, errcode))\n\n        except URLError as error:\n            raise NetworkError('URLError: {0}'.format(error.reason))\n\n        except (SSLError, socket.timeout) as error:\n            err_s = str(error)\n            if 'operation timed out' in err_s:\n                raise TimedOut()\n\n            raise NetworkError(err_s)\n\n        except HTTPException as error:\n            raise NetworkError('HTTPException: {0!r}'.format(error))\n\n    return decorator\n\n\n@_try_except_req\ndef get(url):\n    \"\"\"Request an URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n\n    Returns:\n      A JSON object.\n    \"\"\"\n    result = urlopen(url).read()\n\n    return _parse(result)\n\n\n@_try_except_req\ndef post(url,\n         data,\n         timeout=None,\n         network_delay=2.):\n    \"\"\"Request an URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n      data:\n        A dict of (str, unicode) key/value pairs.\n      timeout:\n        float. If this value is specified, use it as the definitive timeout (in\n        seconds) for urlopen() operations. [Optional]\n      network_delay:\n        float. If using the timeout specified in `data` (which is a timeout for\n        the Telegram servers operation), then `network_delay` as an extra delay\n        (in seconds) to compensate for network latency.\n        default: 2 [Optional]\n\n    Notes:\n      If neither `timeout` nor `data['timeout']` is specified. The underlying\n      defaults are used.\n\n    Returns:\n      A JSON object.\n\n    \"\"\"\n    urlopen_kwargs = {}\n\n    if timeout is not None:\n        urlopen_kwargs['timeout'] = timeout\n    elif 'timeout' in data:\n        urlopen_kwargs['timeout'] = data['timeout'] + network_delay\n\n    if InputFile.is_inputfile(data):\n        data = InputFile(data)\n        request = Request(url,\n                          data=data.to_form(),\n                          headers=data.headers)\n    else:\n        data = json.dumps(data)\n        request = Request(url,\n                          data=data.encode(),\n                          headers={'Content-Type': 'application/json'})\n\n    result = urlopen(request, **urlopen_kwargs).read()\n    return _parse(result)\n\n\n@_try_except_req\ndef download(url,\n             filename):\n    \"\"\"Download a file by its URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n\n      filename:\n        The filename wihtin the path to download the file.\n    \"\"\"\n\n    urlretrieve(url, filename)\n", "path": "telegram/utils/request.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# pylint: disable=no-name-in-module,unused-import\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2016\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\n\"\"\"This module contains methods to make POST and GET requests\"\"\"\n\nimport functools\nimport json\nimport socket\nfrom ssl import SSLError\n\ntry:\n    # python2\n    from httplib import HTTPException\nexcept ImportError:\n    # python3\n    from http.client import HTTPException\n\ntry:\n    # python3\n    from urllib.request import urlopen, urlretrieve, Request\n    from urllib.error import HTTPError, URLError\nexcept ImportError:\n    # python2\n    from urllib import urlretrieve\n    from urllib2 import urlopen, Request, URLError\n    from urllib2 import HTTPError\n\nfrom telegram import (InputFile, TelegramError)\nfrom telegram.error import Unauthorized, NetworkError, TimedOut\n\n\ndef _parse(json_data):\n    \"\"\"Try and parse the JSON returned from Telegram and return an empty\n    dictionary if there is any error.\n\n    Args:\n      url:\n        urllib.urlopen object\n\n    Returns:\n      A JSON parsed as Python dict with results.\n    \"\"\"\n    decoded_s = json_data.decode('utf-8')\n    try:\n        data = json.loads(decoded_s)\n    except ValueError:\n        raise TelegramError('Invalid server response')\n\n    if not data.get('ok') and data.get('description'):\n        return data['description']\n\n    return data['result']\n\n\ndef _try_except_req(func):\n    \"\"\"Decorator for requests to handle known exceptions\"\"\"\n    @functools.wraps(func)\n    def decorator(*args, **kwargs):\n        try:\n            return func(*args, **kwargs)\n\n        except HTTPError as error:\n            # `HTTPError` inherits from `URLError` so `HTTPError` handling must\n            # come first.\n            errcode = error.getcode()\n\n            if errcode in (401, 403):\n                raise Unauthorized()\n            elif errcode == 502:\n                raise NetworkError('Bad Gateway')\n\n            try:\n                message = _parse(error.read())\n            except ValueError:\n                message = 'Unknown HTTPError {0}'.format(error.getcode())\n\n            raise NetworkError('{0} ({1})'.format(message, errcode))\n\n        except URLError as error:\n            raise NetworkError('URLError: {0}'.format(error.reason))\n\n        except (SSLError, socket.timeout) as error:\n            err_s = str(error)\n            if 'operation timed out' in err_s:\n                raise TimedOut()\n\n            raise NetworkError(err_s)\n\n        except HTTPException as error:\n            raise NetworkError('HTTPException: {0!r}'.format(error))\n\n        except socket.error as error:\n            raise NetworkError('socket.error: {0!r}'.format(error))\n\n    return decorator\n\n\n@_try_except_req\ndef get(url):\n    \"\"\"Request an URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n\n    Returns:\n      A JSON object.\n    \"\"\"\n    result = urlopen(url).read()\n\n    return _parse(result)\n\n\n@_try_except_req\ndef post(url,\n         data,\n         timeout=None,\n         network_delay=2.):\n    \"\"\"Request an URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n      data:\n        A dict of (str, unicode) key/value pairs.\n      timeout:\n        float. If this value is specified, use it as the definitive timeout (in\n        seconds) for urlopen() operations. [Optional]\n      network_delay:\n        float. If using the timeout specified in `data` (which is a timeout for\n        the Telegram servers operation), then `network_delay` as an extra delay\n        (in seconds) to compensate for network latency.\n        default: 2 [Optional]\n\n    Notes:\n      If neither `timeout` nor `data['timeout']` is specified. The underlying\n      defaults are used.\n\n    Returns:\n      A JSON object.\n\n    \"\"\"\n    urlopen_kwargs = {}\n\n    if timeout is not None:\n        urlopen_kwargs['timeout'] = timeout\n    elif 'timeout' in data:\n        urlopen_kwargs['timeout'] = data['timeout'] + network_delay\n\n    if InputFile.is_inputfile(data):\n        data = InputFile(data)\n        request = Request(url,\n                          data=data.to_form(),\n                          headers=data.headers)\n    else:\n        data = json.dumps(data)\n        request = Request(url,\n                          data=data.encode(),\n                          headers={'Content-Type': 'application/json'})\n\n    result = urlopen(request, **urlopen_kwargs).read()\n    return _parse(result)\n\n\n@_try_except_req\ndef download(url,\n             filename):\n    \"\"\"Download a file by its URL.\n    Args:\n      url:\n        The web location we want to retrieve.\n\n      filename:\n        The filename wihtin the path to download the file.\n    \"\"\"\n\n    urlretrieve(url, filename)\n", "path": "telegram/utils/request.py"}]}