State dump retry loop for #926.

This is a workaround for "[Errno 9] bad file descriptor" at BoM, in the state dumping code.  It does not close the issue - a similar workaround is still needed in the batched job submission code.

@matthewrmshin, please review.