Skip to content

Commit

Permalink
fix issue spesmilo#105 Thread Exception When building database
Browse files Browse the repository at this point in the history
Go into wait_on_bitcoind instead of raising an exception when an
unexpected bitcoind error number is returned. This allows the server to
wait for bitcoind rather than just bailing out with.
  • Loading branch information
shsmith committed Jul 18, 2015
1 parent e434388 commit 6f30dcb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/blockchain_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,18 @@ def bitcoind(self, method, params=[]):
while True:
try:
respdata = urllib.urlopen(self.bitcoind_url, postdata).read()
except:
print_log("cannot reach bitcoind...")
except BaseException as e:
print_log("cannot reach bitcoind...", str(e))
self.wait_on_bitcoind()
else:
r = loads(respdata)
if r['error'] is not None:
if r['error'].get('code') == -28:
print_log("bitcoind still warming up...")
self.wait_on_bitcoind()
continue
raise BaseException(r['error'])
else:
print_log("bitcoind error...", r['error'])
self.wait_on_bitcoind()
continue
break
return r.get('result')

Expand Down

2 comments on commit 6f30dcb

@ecdsa
Copy link

@ecdsa ecdsa commented on 6f30dcb Jul 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this commit because it makes the server trivially vulnerable; it will close all sessions everytime a client performs a request that returns an error.

@shsmith
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this change can potentially get us into an error loop with a bitcoind request that can never be satisfied.
Maybe a better solution would be a try/catch up it the top of do_catch_up.
It was an exception bubbling up to that function that kills the service in the original issue report.

Please sign in to comment.