Instead of putting the ``safe_run()`` in two places you could perhaps do it once and just add headers like this:

    headers={'If-None-Match': etag} if etag else {}