retry rpc commands

rpc sometimes times out if the machine is under heavy load
lock results.json and deal with corrupted files