Added with_retries decorator to handle IncompleteRead exceptions.