title: why does Contextmanager throws a runtime error 'generator didn't stop after throw()'?
body: <p>In my utility.py I have,</p>
  
  <pre><code>@contextmanager
  def rate_limit_protection(max_tries=3, wait=300):
      tries = 0
      while max_tries &gt; tries:
          try:
              yield
              break
          except FacebookRequestError as e:
              pprint.pprint(e)
              if e._body['error']['message'] == '(#17) User request limit reached':
                  print("waiting...")
                  time.sleep(wait)
                  tries += 1
  </code></pre>
  
  <p>In my task.py I call:</p>
  
  <pre><code>for date in interval:
     with utility.rate_limit_protection():
        stats = account.get_insights(params=params)
  </code></pre>
  
  <p>After runing the task for a given date range, once Facebook rate limit kicks in, the program waits for 300 seconds after which it fails with the error.</p>
  
  <pre><code>File "/Users/kamal/.pyenv/versions/3.4.0/lib/python3.4/contextlib.py", line 78, in __exit__
      raise RuntimeError("generator didn't stop")
  RuntimeError: generator didn't stop
  </code></pre>