MCPcopy Index your code
hub / github.com/webpy/webpy / peep

Method peep

web/application.py:291–303  ·  view source on GitHub ↗

Peeps into an iterator by doing an iteration and returns an equivalent iterator.

(iterator)

Source from the content-addressed store, hash-verified

289 """Returns a WSGI-compatible function for this application."""
290
291 def peep(iterator):
292 """Peeps into an iterator by doing an iteration
293 and returns an equivalent iterator.
294 """
295 # wsgi requires the headers first
296 # so we need to do an iteration
297 # and save the result for later
298 try:
299 firstchunk = next(iterator)
300 except StopIteration:
301 firstchunk = ""
302
303 return itertools.chain([firstchunk], iterator)
304
305 def wsgi(env, start_resp):
306 # clear threadlocal to avoid interference of previous requests

Callers

nothing calls this directly

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected