We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
IPCProvider timeout paramater
* Version: 3.13.5
* Python: 2.7
* OS: Ubuntu 16.04

### What was wrong?
A request has timed out.

Please include any of the following that are applicable:
* The code which produced the error
`web3.manager.request_blocking('parity_pendingTransactions', [])`
* The full output of the error
`
Traceback (most recent call last):
  File "/home/user/clone/mempool/eth.py", line 78, in get_mempool
    'parity_pendingTransactions', []
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/manager.py", line 112, in request_blocking
    response = self._make_request(method, params)
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/manager.py", line 95, in _make_request
    return make_request_fn(method, params)
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/middleware/attrdict.py", line 20, in middleware
    response = make_request(method, params)
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/middleware/formatting.py", line 25, in middleware
    response = make_request(method, params)
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/providers/ipc.py", line 103, in make_request
    timeout.sleep(0)
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/utils/compat/compat_stdlib.py", line 74, in sleep
    self.check()
  File "/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/utils/compat/compat_stdlib.py", line 67, in check
    raise self
Timeout: 10 seconds`
* What type of node you were connecting to
Parity

### How can it be fixed?
Add timeout parameter to IPCProvider class to be able to retry sooner, when a timeout occurs. Right know 10 seconds timeout is hardcoded:  https://github.com/pipermerriam/web3.py/blob/master/web3/providers/ipc.py


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `web3/providers/ipc.py`
Content:
```
1 import os
2 import socket
3 import sys
4 import threading
5 
6 try:
7     from json import JSONDecodeError
8 except ImportError:
9     JSONDecodeError = ValueError
10 
11 from web3.utils.threads import (
12     Timeout,
13 )
14 
15 from .base import JSONBaseProvider
16 
17 
18 def get_ipc_socket(ipc_path, timeout=0.1):
19     if sys.platform == 'win32':
20         # On Windows named pipe is used. Simulate socket with it.
21         from web3.utils.windows import NamedPipe
22 
23         return NamedPipe(ipc_path)
24     else:
25         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
26         sock.connect(ipc_path)
27         sock.settimeout(timeout)
28         return sock
29 
30 
31 class PersistantSocket(object):
32     sock = None
33 
34     def __init__(self, ipc_path):
35         self.ipc_path = ipc_path
36 
37     def __enter__(self):
38         if not self.ipc_path:
39             raise FileNotFoundError("cannot connect to IPC socket at path: %r" % self.ipc_path)
40 
41         if not self.sock:
42             self.sock = self._open()
43         return self.sock
44 
45     def __exit__(self, exc_type, exc_value, traceback):
46         # only close the socket if there was an error
47         if exc_value is not None:
48             try:
49                 self.sock.close()
50             except Exception:
51                 pass
52             self.sock = None
53 
54     def _open(self):
55         return get_ipc_socket(self.ipc_path)
56 
57     def reset(self):
58         self.sock.close()
59         self.sock = self._open()
60         return self.sock
61 
62 
63 def get_default_ipc_path(testnet=False):
64     if testnet:
65         testnet = "testnet"
66     else:
67         testnet = ""
68 
69     if sys.platform == 'darwin':
70         ipc_path = os.path.expanduser(os.path.join(
71             "~",
72             "Library",
73             "Ethereum",
74             testnet,
75             "geth.ipc"
76         ))
77         if os.path.exists(ipc_path):
78             return ipc_path
79 
80         ipc_path = os.path.expanduser(os.path.join(
81             "~",
82             "Library",
83             "Application Support",
84             "io.parity.ethereum",
85             "jsonrpc.ipc"
86         ))
87         if os.path.exists(ipc_path):
88             return ipc_path
89 
90     elif sys.platform.startswith('linux'):
91         ipc_path = os.path.expanduser(os.path.join(
92             "~",
93             ".ethereum",
94             testnet,
95             "geth.ipc"
96         ))
97         if os.path.exists(ipc_path):
98             return ipc_path
99 
100         ipc_path = os.path.expanduser(os.path.join(
101             "~",
102             ".local",
103             "share",
104             "io.parity.ethereum",
105             "jsonrpc.ipc"
106         ))
107         if os.path.exists(ipc_path):
108             return ipc_path
109 
110     elif sys.platform == 'win32':
111         ipc_path = os.path.join(
112             "\\\\",
113             ".",
114             "pipe",
115             "geth.ipc"
116         )
117         if os.path.exists(ipc_path):
118             return ipc_path
119 
120         ipc_path = os.path.join(
121             "\\\\",
122             ".",
123             "pipe",
124             "jsonrpc.ipc"
125         )
126         if os.path.exists(ipc_path):
127             return ipc_path
128 
129     else:
130         raise ValueError(
131             "Unsupported platform '{0}'.  Only darwin/linux2/win32 are "
132             "supported.  You must specify the ipc_path".format(sys.platform)
133         )
134 
135 
136 class IPCProvider(JSONBaseProvider):
137     _socket = None
138 
139     def __init__(self, ipc_path=None, testnet=False, *args, **kwargs):
140         if ipc_path is None:
141             self.ipc_path = get_default_ipc_path(testnet)
142         else:
143             self.ipc_path = ipc_path
144 
145         self._lock = threading.Lock()
146         self._socket = PersistantSocket(self.ipc_path)
147         super(IPCProvider, self).__init__(*args, **kwargs)
148 
149     def make_request(self, method, params):
150         request = self.encode_rpc_request(method, params)
151 
152         with self._lock, self._socket as sock:
153             try:
154                 sock.sendall(request)
155             except BrokenPipeError:
156                 # one extra attempt, then give up
157                 sock = self._socket.reset()
158                 sock.sendall(request)
159 
160             raw_response = b""
161             with Timeout(10) as timeout:
162                 while True:
163                     try:
164                         raw_response += sock.recv(4096)
165                     except socket.timeout:
166                         timeout.sleep(0)
167                         continue
168                     if raw_response == b"":
169                         timeout.sleep(0)
170                     else:
171                         try:
172                             response = self.decode_rpc_response(raw_response)
173                         except JSONDecodeError:
174                             timeout.sleep(0)
175                             continue
176                         else:
177                             return response
178
```
--- 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/web3/providers/ipc.py b/web3/providers/ipc.py
--- a/web3/providers/ipc.py
+++ b/web3/providers/ipc.py
@@ -136,12 +136,13 @@
 class IPCProvider(JSONBaseProvider):
     _socket = None
 
-    def __init__(self, ipc_path=None, testnet=False, *args, **kwargs):
+    def __init__(self, ipc_path=None, testnet=False, timeout=10, *args, **kwargs):
         if ipc_path is None:
             self.ipc_path = get_default_ipc_path(testnet)
         else:
             self.ipc_path = ipc_path
 
+        self.timeout = timeout
         self._lock = threading.Lock()
         self._socket = PersistantSocket(self.ipc_path)
         super(IPCProvider, self).__init__(*args, **kwargs)
@@ -158,7 +159,7 @@
                 sock.sendall(request)
 
             raw_response = b""
-            with Timeout(10) as timeout:
+            with Timeout(self.timeout) as timeout:
                 while True:
                     try:
                         raw_response += sock.recv(4096)

{"golden_diff": "diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py\n--- a/web3/providers/ipc.py\n+++ b/web3/providers/ipc.py\n@@ -136,12 +136,13 @@\n class IPCProvider(JSONBaseProvider):\n     _socket = None\n \n-    def __init__(self, ipc_path=None, testnet=False, *args, **kwargs):\n+    def __init__(self, ipc_path=None, testnet=False, timeout=10, *args, **kwargs):\n         if ipc_path is None:\n             self.ipc_path = get_default_ipc_path(testnet)\n         else:\n             self.ipc_path = ipc_path\n \n+        self.timeout = timeout\n         self._lock = threading.Lock()\n         self._socket = PersistantSocket(self.ipc_path)\n         super(IPCProvider, self).__init__(*args, **kwargs)\n@@ -158,7 +159,7 @@\n                 sock.sendall(request)\n \n             raw_response = b\"\"\n-            with Timeout(10) as timeout:\n+            with Timeout(self.timeout) as timeout:\n                 while True:\n                     try:\n                         raw_response += sock.recv(4096)\n", "issue": "IPCProvider timeout paramater\n* Version: 3.13.5\r\n* Python: 2.7\r\n* OS: Ubuntu 16.04\r\n\r\n### What was wrong?\r\nA request has timed out.\r\n\r\nPlease include any of the following that are applicable:\r\n* The code which produced the error\r\n`web3.manager.request_blocking('parity_pendingTransactions', [])`\r\n* The full output of the error\r\n`\r\nTraceback (most recent call last):\r\n  File \"/home/user/clone/mempool/eth.py\", line 78, in get_mempool\r\n    'parity_pendingTransactions', []\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/manager.py\", line 112, in request_blocking\r\n    response = self._make_request(method, params)\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/manager.py\", line 95, in _make_request\r\n    return make_request_fn(method, params)\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/middleware/attrdict.py\", line 20, in middleware\r\n    response = make_request(method, params)\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/middleware/formatting.py\", line 25, in middleware\r\n    response = make_request(method, params)\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/providers/ipc.py\", line 103, in make_request\r\n    timeout.sleep(0)\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/utils/compat/compat_stdlib.py\", line 74, in sleep\r\n    self.check()\r\n  File \"/home/user/.virtualenvs/prune/local/lib/python2.7/site-packages/web3/utils/compat/compat_stdlib.py\", line 67, in check\r\n    raise self\r\nTimeout: 10 seconds`\r\n* What type of node you were connecting to\r\nParity\r\n\r\n### How can it be fixed?\r\nAdd timeout parameter to IPCProvider class to be able to retry sooner, when a timeout occurs. Right know 10 seconds timeout is hardcoded:  https://github.com/pipermerriam/web3.py/blob/master/web3/providers/ipc.py\r\n\n", "before_files": [{"content": "import os\nimport socket\nimport sys\nimport threading\n\ntry:\n    from json import JSONDecodeError\nexcept ImportError:\n    JSONDecodeError = ValueError\n\nfrom web3.utils.threads import (\n    Timeout,\n)\n\nfrom .base import JSONBaseProvider\n\n\ndef get_ipc_socket(ipc_path, timeout=0.1):\n    if sys.platform == 'win32':\n        # On Windows named pipe is used. Simulate socket with it.\n        from web3.utils.windows import NamedPipe\n\n        return NamedPipe(ipc_path)\n    else:\n        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n        sock.connect(ipc_path)\n        sock.settimeout(timeout)\n        return sock\n\n\nclass PersistantSocket(object):\n    sock = None\n\n    def __init__(self, ipc_path):\n        self.ipc_path = ipc_path\n\n    def __enter__(self):\n        if not self.ipc_path:\n            raise FileNotFoundError(\"cannot connect to IPC socket at path: %r\" % self.ipc_path)\n\n        if not self.sock:\n            self.sock = self._open()\n        return self.sock\n\n    def __exit__(self, exc_type, exc_value, traceback):\n        # only close the socket if there was an error\n        if exc_value is not None:\n            try:\n                self.sock.close()\n            except Exception:\n                pass\n            self.sock = None\n\n    def _open(self):\n        return get_ipc_socket(self.ipc_path)\n\n    def reset(self):\n        self.sock.close()\n        self.sock = self._open()\n        return self.sock\n\n\ndef get_default_ipc_path(testnet=False):\n    if testnet:\n        testnet = \"testnet\"\n    else:\n        testnet = \"\"\n\n    if sys.platform == 'darwin':\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \"Library\",\n            \"Ethereum\",\n            testnet,\n            \"geth.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \"Library\",\n            \"Application Support\",\n            \"io.parity.ethereum\",\n            \"jsonrpc.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    elif sys.platform.startswith('linux'):\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \".ethereum\",\n            testnet,\n            \"geth.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \".local\",\n            \"share\",\n            \"io.parity.ethereum\",\n            \"jsonrpc.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    elif sys.platform == 'win32':\n        ipc_path = os.path.join(\n            \"\\\\\\\\\",\n            \".\",\n            \"pipe\",\n            \"geth.ipc\"\n        )\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.join(\n            \"\\\\\\\\\",\n            \".\",\n            \"pipe\",\n            \"jsonrpc.ipc\"\n        )\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    else:\n        raise ValueError(\n            \"Unsupported platform '{0}'.  Only darwin/linux2/win32 are \"\n            \"supported.  You must specify the ipc_path\".format(sys.platform)\n        )\n\n\nclass IPCProvider(JSONBaseProvider):\n    _socket = None\n\n    def __init__(self, ipc_path=None, testnet=False, *args, **kwargs):\n        if ipc_path is None:\n            self.ipc_path = get_default_ipc_path(testnet)\n        else:\n            self.ipc_path = ipc_path\n\n        self._lock = threading.Lock()\n        self._socket = PersistantSocket(self.ipc_path)\n        super(IPCProvider, self).__init__(*args, **kwargs)\n\n    def make_request(self, method, params):\n        request = self.encode_rpc_request(method, params)\n\n        with self._lock, self._socket as sock:\n            try:\n                sock.sendall(request)\n            except BrokenPipeError:\n                # one extra attempt, then give up\n                sock = self._socket.reset()\n                sock.sendall(request)\n\n            raw_response = b\"\"\n            with Timeout(10) as timeout:\n                while True:\n                    try:\n                        raw_response += sock.recv(4096)\n                    except socket.timeout:\n                        timeout.sleep(0)\n                        continue\n                    if raw_response == b\"\":\n                        timeout.sleep(0)\n                    else:\n                        try:\n                            response = self.decode_rpc_response(raw_response)\n                        except JSONDecodeError:\n                            timeout.sleep(0)\n                            continue\n                        else:\n                            return response\n", "path": "web3/providers/ipc.py"}], "after_files": [{"content": "import os\nimport socket\nimport sys\nimport threading\n\ntry:\n    from json import JSONDecodeError\nexcept ImportError:\n    JSONDecodeError = ValueError\n\nfrom web3.utils.threads import (\n    Timeout,\n)\n\nfrom .base import JSONBaseProvider\n\n\ndef get_ipc_socket(ipc_path, timeout=0.1):\n    if sys.platform == 'win32':\n        # On Windows named pipe is used. Simulate socket with it.\n        from web3.utils.windows import NamedPipe\n\n        return NamedPipe(ipc_path)\n    else:\n        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n        sock.connect(ipc_path)\n        sock.settimeout(timeout)\n        return sock\n\n\nclass PersistantSocket(object):\n    sock = None\n\n    def __init__(self, ipc_path):\n        self.ipc_path = ipc_path\n\n    def __enter__(self):\n        if not self.ipc_path:\n            raise FileNotFoundError(\"cannot connect to IPC socket at path: %r\" % self.ipc_path)\n\n        if not self.sock:\n            self.sock = self._open()\n        return self.sock\n\n    def __exit__(self, exc_type, exc_value, traceback):\n        # only close the socket if there was an error\n        if exc_value is not None:\n            try:\n                self.sock.close()\n            except Exception:\n                pass\n            self.sock = None\n\n    def _open(self):\n        return get_ipc_socket(self.ipc_path)\n\n    def reset(self):\n        self.sock.close()\n        self.sock = self._open()\n        return self.sock\n\n\ndef get_default_ipc_path(testnet=False):\n    if testnet:\n        testnet = \"testnet\"\n    else:\n        testnet = \"\"\n\n    if sys.platform == 'darwin':\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \"Library\",\n            \"Ethereum\",\n            testnet,\n            \"geth.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \"Library\",\n            \"Application Support\",\n            \"io.parity.ethereum\",\n            \"jsonrpc.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    elif sys.platform.startswith('linux'):\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \".ethereum\",\n            testnet,\n            \"geth.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.expanduser(os.path.join(\n            \"~\",\n            \".local\",\n            \"share\",\n            \"io.parity.ethereum\",\n            \"jsonrpc.ipc\"\n        ))\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    elif sys.platform == 'win32':\n        ipc_path = os.path.join(\n            \"\\\\\\\\\",\n            \".\",\n            \"pipe\",\n            \"geth.ipc\"\n        )\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n        ipc_path = os.path.join(\n            \"\\\\\\\\\",\n            \".\",\n            \"pipe\",\n            \"jsonrpc.ipc\"\n        )\n        if os.path.exists(ipc_path):\n            return ipc_path\n\n    else:\n        raise ValueError(\n            \"Unsupported platform '{0}'.  Only darwin/linux2/win32 are \"\n            \"supported.  You must specify the ipc_path\".format(sys.platform)\n        )\n\n\nclass IPCProvider(JSONBaseProvider):\n    _socket = None\n\n    def __init__(self, ipc_path=None, testnet=False, timeout=10, *args, **kwargs):\n        if ipc_path is None:\n            self.ipc_path = get_default_ipc_path(testnet)\n        else:\n            self.ipc_path = ipc_path\n\n        self.timeout = timeout\n        self._lock = threading.Lock()\n        self._socket = PersistantSocket(self.ipc_path)\n        super(IPCProvider, self).__init__(*args, **kwargs)\n\n    def make_request(self, method, params):\n        request = self.encode_rpc_request(method, params)\n\n        with self._lock, self._socket as sock:\n            try:\n                sock.sendall(request)\n            except BrokenPipeError:\n                # one extra attempt, then give up\n                sock = self._socket.reset()\n                sock.sendall(request)\n\n            raw_response = b\"\"\n            with Timeout(self.timeout) as timeout:\n                while True:\n                    try:\n                        raw_response += sock.recv(4096)\n                    except socket.timeout:\n                        timeout.sleep(0)\n                        continue\n                    if raw_response == b\"\":\n                        timeout.sleep(0)\n                    else:\n                        try:\n                            response = self.decode_rpc_response(raw_response)\n                        except JSONDecodeError:\n                            timeout.sleep(0)\n                            continue\n                        else:\n                            return response\n", "path": "web3/providers/ipc.py"}]}