Repository: ethereum/web3.py

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



Discussion:
Are you seeing 10s timeouts followed by successful lookups on retry?
I have no way to verify this, but will check it, if it happens again.
Is there already a pull request or a specific branch that has the timeout included?
@sbaks0820 no, this hasn't been done but it should be a small change if you'd like to give it a go.

Resolving patch:
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 @@ def get_default_ipc_path(testnet=False):
 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 @@ def make_request(self, method, params):
                 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)


Test patch: