title: R avoiding "restarting interrupted promise evaluation" warning
body: <h2>Problem</h2>
  
  <p>It seems that within a function, when you evaluate an expression that yields an error more than once, you get the warning <code>restarting interrupted promise evaluation</code>. For instance:</p>
  
  <pre><code>foo &lt;- function() stop("Foo error")
  bar &lt;- function(x) {
      try(x)
      x
  }
  bar(foo())
  </code></pre>
  
  <p>yields</p>
  
  <pre><code>Error in foo() : Foo error
  Error in foo() : Foo error
  In addition: Warning message:
  In bar(foo()) : restarting interrupted promise evaluation
  </code></pre>
  
  <p>How to avoid this warning and deal with it properly?</p>
  
  <h2>Background</h2>
  
  <p>Especially with operations like writing to a database, you might encounter locking errors that require you to retry your operation a few times. Hence I'm creating a wrapper around <code>tryCatch</code> that re-evaluates an expression up to <code>n</code> times until successful:</p>
  
  <pre><code>tryAgain &lt;- function(expr, n = 3) {
      success &lt;- T
      for (i in 1:n) {
          res &lt;- tryCatch(expr,
              error = function(e) {
                  print(sprintf("Log error to file: %s", conditionMessage(e)))
                  success &lt;&lt;- F
                  e
              }
          )
          if (success) break
      }
      res
  }
  </code></pre>
  
  <p>However, I'm getting loads of <code>restarting interrupted promise evaluation</code> messages:</p>
  
  <pre><code>&gt;   tryAgain(foo())
  [1] "Log error to file: Foo error"
  [1] "Log error to file: Foo error"
  [1] "Log error to file: Foo error"
  &lt;simpleError in foo(): Foo error&gt;
  Warning messages:
  1: In doTryCatch(return(expr), name, parentenv, handler) :
    restarting interrupted promise evaluation
  2: In doTryCatch(return(expr), name, parentenv, handler) :
    restarting interrupted promise evaluation
  </code></pre>
  
  <p>Ideally I want to avoid these messages altogether rather than just muffle them, since I might also want to handle genuine warnings coming from <code>expr</code>.</p>