Skip to content

Commit

Permalink
Merge pull request HelloZeroNet#418 from TheNain38/patch-1
Browse files Browse the repository at this point in the history
Exception handling when connecting first time
  • Loading branch information
HelloZeroNet committed Apr 14, 2016
2 parents e3a4dba + 6c9da8a commit 3d157af
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugins/Zeroname/updater/zeroname_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,19 @@ def initRpc(config):
# Initialize rpc connection
rpc_auth, rpc_timeout = initRpc(namecoin_location + "namecoin.conf")
rpc = AuthServiceProxy(rpc_auth, timeout=rpc_timeout)
last_block = int(rpc.getinfo()["blocks"])

while 1:
try:
time.sleep(1)
last_block = int(rpc.getinfo()["blocks"])
break # Connection succeeded
except socket.timeout: # Timeout
print ".",
sys.stdout.flush()
except Exception, err:
print "Exception", err.__class__, err
time.sleep(5)
rpc = AuthServiceProxy(rpc_auth, timeout=rpc_timeout)

if not config["lastprocessed"]: # First startup: Start processing from last block
config["lastprocessed"] = last_block
Expand Down

0 comments on commit 3d157af

Please sign in to comment.