Merge pull request #418 from TheNain38/patch-1

Exception handling when connecting first time
This commit is contained in:
ZeroNet 2016-04-14 17:40:08 +02:00
commit 3d157af915
1 changed files with 13 additions and 1 deletions

View File

@ -144,7 +144,19 @@ if sys.platform == 'win32':
# 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