Ejemplo n.º 1
0
 def __iter__(self):
     if self.peeked_chunk is not None:
         pc = self.peeked_chunk
         self.peeked_chunk = None
         return CloseableChain([pc], self.app_iter)
     else:
         return self.app_iter
Ejemplo n.º 2
0
 def _app_call(self, env):
     """
     Ensures start_response has been called before returning.
     """
     self._response_status = None
     self._response_headers = None
     self._response_exc_info = None
     resp = self.app(env, self._start_response)
     # if start_response has been called, just return the iter
     if self._response_status is not None:
         return resp
     resp = iter(resp)
     try:
         first_chunk = resp.next()
     except StopIteration:
         return iter([])
     else:  # We got a first_chunk
         return CloseableChain([first_chunk], resp)