State dump retry loop for #926.

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