We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cannot wait blocking generator output from events()
Since upgrade to `docker 2.2.0`. 

API 'events()' using same API client time out. 
So I got `UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.` exception message.

But in my use case, `containers()` or other client APIs are reasonable to set an default timeout.
But `events()` should have another timeout setting for users.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/api/daemon.py`
Content:
```
1 import os
2 import warnings
3 from datetime import datetime
4 
5 from .. import auth, utils
6 from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
7 
8 
9 class DaemonApiMixin(object):
10     @utils.minimum_version('1.25')
11     def df(self):
12         """
13         Get data usage information.
14 
15         Returns:
16             (dict): A dictionary representing different resource categories
17             and their respective data usage.
18 
19         Raises:
20             :py:class:`docker.errors.APIError`
21                 If the server returns an error.
22         """
23         url = self._url('/system/df')
24         return self._result(self._get(url), True)
25 
26     def events(self, since=None, until=None, filters=None, decode=None):
27         """
28         Get real-time events from the server. Similar to the ``docker events``
29         command.
30 
31         Args:
32             since (UTC datetime or int): Get events from this point
33             until (UTC datetime or int): Get events until this point
34             filters (dict): Filter the events by event time, container or image
35             decode (bool): If set to true, stream will be decoded into dicts on
36                 the fly. False by default.
37 
38         Returns:
39             (generator): A blocking generator you can iterate over to retrieve
40                 events as they happen.
41 
42         Raises:
43             :py:class:`docker.errors.APIError`
44                 If the server returns an error.
45 
46         Example:
47 
48             >>> for event in client.events()
49             ...   print event
50             {u'from': u'image/with:tag',
51              u'id': u'container-id',
52              u'status': u'start',
53              u'time': 1423339459}
54             ...
55         """
56 
57         if isinstance(since, datetime):
58             since = utils.datetime_to_timestamp(since)
59 
60         if isinstance(until, datetime):
61             until = utils.datetime_to_timestamp(until)
62 
63         if filters:
64             filters = utils.convert_filters(filters)
65 
66         params = {
67             'since': since,
68             'until': until,
69             'filters': filters
70         }
71 
72         return self._stream_helper(
73             self._get(self._url('/events'), params=params, stream=True),
74             decode=decode
75         )
76 
77     def info(self):
78         """
79         Display system-wide information. Identical to the ``docker info``
80         command.
81 
82         Returns:
83             (dict): The info as a dict
84 
85         Raises:
86             :py:class:`docker.errors.APIError`
87                 If the server returns an error.
88         """
89         return self._result(self._get(self._url("/info")), True)
90 
91     def login(self, username, password=None, email=None, registry=None,
92               reauth=False, insecure_registry=False, dockercfg_path=None):
93         """
94         Authenticate with a registry. Similar to the ``docker login`` command.
95 
96         Args:
97             username (str): The registry username
98             password (str): The plaintext password
99             email (str): The email for the registry account
100             registry (str): URL to the registry.  E.g.
101                 ``https://index.docker.io/v1/``
102             reauth (bool): Whether refresh existing authentication on the
103                 Docker server.
104             dockercfg_path (str): Use a custom path for the ``.dockercfg`` file
105         (default ``$HOME/.dockercfg``)
106 
107         Returns:
108             (dict): The response from the login request
109 
110         Raises:
111             :py:class:`docker.errors.APIError`
112                 If the server returns an error.
113         """
114         if insecure_registry:
115             warnings.warn(
116                 INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),
117                 DeprecationWarning
118             )
119 
120         # If we don't have any auth data so far, try reloading the config file
121         # one more time in case anything showed up in there.
122         # If dockercfg_path is passed check to see if the config file exists,
123         # if so load that config.
124         if dockercfg_path and os.path.exists(dockercfg_path):
125             self._auth_configs = auth.load_config(dockercfg_path)
126         elif not self._auth_configs:
127             self._auth_configs = auth.load_config()
128 
129         authcfg = auth.resolve_authconfig(self._auth_configs, registry)
130         # If we found an existing auth config for this registry and username
131         # combination, we can return it immediately unless reauth is requested.
132         if authcfg and authcfg.get('username', None) == username \
133                 and not reauth:
134             return authcfg
135 
136         req_data = {
137             'username': username,
138             'password': password,
139             'email': email,
140             'serveraddress': registry,
141         }
142 
143         response = self._post_json(self._url('/auth'), data=req_data)
144         if response.status_code == 200:
145             self._auth_configs[registry or auth.INDEX_NAME] = req_data
146         return self._result(response, json=True)
147 
148     def ping(self):
149         """
150         Checks the server is responsive. An exception will be raised if it
151         isn't responding.
152 
153         Returns:
154             (bool) The response from the server.
155 
156         Raises:
157             :py:class:`docker.errors.APIError`
158                 If the server returns an error.
159         """
160         return self._result(self._get(self._url('/_ping'))) == 'OK'
161 
162     def version(self, api_version=True):
163         """
164         Returns version information from the server. Similar to the ``docker
165         version`` command.
166 
167         Returns:
168             (dict): The server version information
169 
170         Raises:
171             :py:class:`docker.errors.APIError`
172                 If the server returns an error.
173         """
174         url = self._url("/version", versioned_api=api_version)
175         return self._result(self._get(url), json=True)
176
```
--- 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/docker/api/daemon.py b/docker/api/daemon.py
--- a/docker/api/daemon.py
+++ b/docker/api/daemon.py
@@ -68,9 +68,10 @@
             'until': until,
             'filters': filters
         }
+        url = self._url('/events')
 
         return self._stream_helper(
-            self._get(self._url('/events'), params=params, stream=True),
+            self._get(url, params=params, stream=True, timeout=None),
             decode=decode
         )

{"golden_diff": "diff --git a/docker/api/daemon.py b/docker/api/daemon.py\n--- a/docker/api/daemon.py\n+++ b/docker/api/daemon.py\n@@ -68,9 +68,10 @@\n             'until': until,\n             'filters': filters\n         }\n+        url = self._url('/events')\n \n         return self._stream_helper(\n-            self._get(self._url('/events'), params=params, stream=True),\n+            self._get(url, params=params, stream=True, timeout=None),\n             decode=decode\n         )\n", "issue": "Cannot wait blocking generator output from events()\nSince upgrade to `docker 2.2.0`. \r\n\r\nAPI 'events()' using same API client time out. \r\nSo I got `UnixHTTPConnectionPool(host='localhost', port=None): Read timed out.` exception message.\r\n\r\nBut in my use case, `containers()` or other client APIs are reasonable to set an default timeout.\r\nBut `events()` should have another timeout setting for users.\n", "before_files": [{"content": "import os\nimport warnings\nfrom datetime import datetime\n\nfrom .. import auth, utils\nfrom ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING\n\n\nclass DaemonApiMixin(object):\n    @utils.minimum_version('1.25')\n    def df(self):\n        \"\"\"\n        Get data usage information.\n\n        Returns:\n            (dict): A dictionary representing different resource categories\n            and their respective data usage.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url('/system/df')\n        return self._result(self._get(url), True)\n\n    def events(self, since=None, until=None, filters=None, decode=None):\n        \"\"\"\n        Get real-time events from the server. Similar to the ``docker events``\n        command.\n\n        Args:\n            since (UTC datetime or int): Get events from this point\n            until (UTC datetime or int): Get events until this point\n            filters (dict): Filter the events by event time, container or image\n            decode (bool): If set to true, stream will be decoded into dicts on\n                the fly. False by default.\n\n        Returns:\n            (generator): A blocking generator you can iterate over to retrieve\n                events as they happen.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> for event in client.events()\n            ...   print event\n            {u'from': u'image/with:tag',\n             u'id': u'container-id',\n             u'status': u'start',\n             u'time': 1423339459}\n            ...\n        \"\"\"\n\n        if isinstance(since, datetime):\n            since = utils.datetime_to_timestamp(since)\n\n        if isinstance(until, datetime):\n            until = utils.datetime_to_timestamp(until)\n\n        if filters:\n            filters = utils.convert_filters(filters)\n\n        params = {\n            'since': since,\n            'until': until,\n            'filters': filters\n        }\n\n        return self._stream_helper(\n            self._get(self._url('/events'), params=params, stream=True),\n            decode=decode\n        )\n\n    def info(self):\n        \"\"\"\n        Display system-wide information. Identical to the ``docker info``\n        command.\n\n        Returns:\n            (dict): The info as a dict\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url(\"/info\")), True)\n\n    def login(self, username, password=None, email=None, registry=None,\n              reauth=False, insecure_registry=False, dockercfg_path=None):\n        \"\"\"\n        Authenticate with a registry. Similar to the ``docker login`` command.\n\n        Args:\n            username (str): The registry username\n            password (str): The plaintext password\n            email (str): The email for the registry account\n            registry (str): URL to the registry.  E.g.\n                ``https://index.docker.io/v1/``\n            reauth (bool): Whether refresh existing authentication on the\n                Docker server.\n            dockercfg_path (str): Use a custom path for the ``.dockercfg`` file\n        (default ``$HOME/.dockercfg``)\n\n        Returns:\n            (dict): The response from the login request\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        if insecure_registry:\n            warnings.warn(\n                INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),\n                DeprecationWarning\n            )\n\n        # If we don't have any auth data so far, try reloading the config file\n        # one more time in case anything showed up in there.\n        # If dockercfg_path is passed check to see if the config file exists,\n        # if so load that config.\n        if dockercfg_path and os.path.exists(dockercfg_path):\n            self._auth_configs = auth.load_config(dockercfg_path)\n        elif not self._auth_configs:\n            self._auth_configs = auth.load_config()\n\n        authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n        # If we found an existing auth config for this registry and username\n        # combination, we can return it immediately unless reauth is requested.\n        if authcfg and authcfg.get('username', None) == username \\\n                and not reauth:\n            return authcfg\n\n        req_data = {\n            'username': username,\n            'password': password,\n            'email': email,\n            'serveraddress': registry,\n        }\n\n        response = self._post_json(self._url('/auth'), data=req_data)\n        if response.status_code == 200:\n            self._auth_configs[registry or auth.INDEX_NAME] = req_data\n        return self._result(response, json=True)\n\n    def ping(self):\n        \"\"\"\n        Checks the server is responsive. An exception will be raised if it\n        isn't responding.\n\n        Returns:\n            (bool) The response from the server.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url('/_ping'))) == 'OK'\n\n    def version(self, api_version=True):\n        \"\"\"\n        Returns version information from the server. Similar to the ``docker\n        version`` command.\n\n        Returns:\n            (dict): The server version information\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url(\"/version\", versioned_api=api_version)\n        return self._result(self._get(url), json=True)\n", "path": "docker/api/daemon.py"}], "after_files": [{"content": "import os\nimport warnings\nfrom datetime import datetime\n\nfrom .. import auth, utils\nfrom ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING\n\n\nclass DaemonApiMixin(object):\n    @utils.minimum_version('1.25')\n    def df(self):\n        \"\"\"\n        Get data usage information.\n\n        Returns:\n            (dict): A dictionary representing different resource categories\n            and their respective data usage.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url('/system/df')\n        return self._result(self._get(url), True)\n\n    def events(self, since=None, until=None, filters=None, decode=None):\n        \"\"\"\n        Get real-time events from the server. Similar to the ``docker events``\n        command.\n\n        Args:\n            since (UTC datetime or int): Get events from this point\n            until (UTC datetime or int): Get events until this point\n            filters (dict): Filter the events by event time, container or image\n            decode (bool): If set to true, stream will be decoded into dicts on\n                the fly. False by default.\n\n        Returns:\n            (generator): A blocking generator you can iterate over to retrieve\n                events as they happen.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> for event in client.events()\n            ...   print event\n            {u'from': u'image/with:tag',\n             u'id': u'container-id',\n             u'status': u'start',\n             u'time': 1423339459}\n            ...\n        \"\"\"\n\n        if isinstance(since, datetime):\n            since = utils.datetime_to_timestamp(since)\n\n        if isinstance(until, datetime):\n            until = utils.datetime_to_timestamp(until)\n\n        if filters:\n            filters = utils.convert_filters(filters)\n\n        params = {\n            'since': since,\n            'until': until,\n            'filters': filters\n        }\n        url = self._url('/events')\n\n        return self._stream_helper(\n            self._get(url, params=params, stream=True, timeout=None),\n            decode=decode\n        )\n\n    def info(self):\n        \"\"\"\n        Display system-wide information. Identical to the ``docker info``\n        command.\n\n        Returns:\n            (dict): The info as a dict\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url(\"/info\")), True)\n\n    def login(self, username, password=None, email=None, registry=None,\n              reauth=False, insecure_registry=False, dockercfg_path=None):\n        \"\"\"\n        Authenticate with a registry. Similar to the ``docker login`` command.\n\n        Args:\n            username (str): The registry username\n            password (str): The plaintext password\n            email (str): The email for the registry account\n            registry (str): URL to the registry.  E.g.\n                ``https://index.docker.io/v1/``\n            reauth (bool): Whether refresh existing authentication on the\n                Docker server.\n            dockercfg_path (str): Use a custom path for the ``.dockercfg`` file\n        (default ``$HOME/.dockercfg``)\n\n        Returns:\n            (dict): The response from the login request\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        if insecure_registry:\n            warnings.warn(\n                INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),\n                DeprecationWarning\n            )\n\n        # If we don't have any auth data so far, try reloading the config file\n        # one more time in case anything showed up in there.\n        # If dockercfg_path is passed check to see if the config file exists,\n        # if so load that config.\n        if dockercfg_path and os.path.exists(dockercfg_path):\n            self._auth_configs = auth.load_config(dockercfg_path)\n        elif not self._auth_configs:\n            self._auth_configs = auth.load_config()\n\n        authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n        # If we found an existing auth config for this registry and username\n        # combination, we can return it immediately unless reauth is requested.\n        if authcfg and authcfg.get('username', None) == username \\\n                and not reauth:\n            return authcfg\n\n        req_data = {\n            'username': username,\n            'password': password,\n            'email': email,\n            'serveraddress': registry,\n        }\n\n        response = self._post_json(self._url('/auth'), data=req_data)\n        if response.status_code == 200:\n            self._auth_configs[registry or auth.INDEX_NAME] = req_data\n        return self._result(response, json=True)\n\n    def ping(self):\n        \"\"\"\n        Checks the server is responsive. An exception will be raised if it\n        isn't responding.\n\n        Returns:\n            (bool) The response from the server.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url('/_ping'))) == 'OK'\n\n    def version(self, api_version=True):\n        \"\"\"\n        Returns version information from the server. Similar to the ``docker\n        version`` command.\n\n        Returns:\n            (dict): The server version information\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url(\"/version\", versioned_api=api_version)\n        return self._result(self._get(url), json=True)\n", "path": "docker/api/daemon.py"}]}