1
Thanks in advance. If I call getblockchaininfo through bitcoin-cli it just works. It might take a while but it works all the time. If I call it from within a Python Script
from bitcoin.rpc import RawProxy
...
# create a connection to local Bitcoin Core node
p = RawProxy()
...
info = p.getblockchaininfo()
...
then 8 out of 10 times it breaks...
~$python .bitcoin/blockheigh.py
Traceback (most recent call last):
File ".bitcoin/blockheigh.py", line 58, in <module>
info = p.getblockchaininfo()
File "/home/user/.local/lib/python2.7/site-packages/bitcoin/rpc.py", line 296, in <lambda>
f = lambda *args: self._call(name, *args)
File "/home/user/.local/lib/python2.7/site-packages/bitcoin/rpc.py", line 229, in _call
response = self._get_response()
File "/home/user/.local/lib/python2.7/site-packages/bitcoin/rpc.py", line 254, in _get_response
http_response = self.__conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1136, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
socket.timeout: timed out
How can I force it to wait for the response?
Thanks
This is a good question. How do I set a timeout when I use a library that is doing the
connect()? – Ben – 2019-08-29T08:37:29.290You just need to use the socket
settimeout()method before attempting theconnect()so you wait for the response. – Adam – 2018-06-25T14:49:09.443Is
settimeout()part ofRawProxy? I can't find it – Jusoaresf – 2018-06-26T10:38:15.893