MCPcopy
hub / github.com/aio-libs/aiohttp / _sendfile_cb

Method _sendfile_cb

aiohttp/web_urldispatcher.py:484–502  ·  view source on GitHub ↗
(self, fut, out_fd, in_fd, offset, count, loop,
                     registered)

Source from the content-addressed store, hash-verified

482 'prefix': self._prefix}
483
484 def _sendfile_cb(self, fut, out_fd, in_fd, offset, count, loop,
485 registered):
486 if registered:
487 loop.remove_writer(out_fd)
488 try:
489 n = os.sendfile(out_fd, in_fd, offset, count)
490 if n == 0: # EOF reached
491 n = count
492 except (BlockingIOError, InterruptedError):
493 n = 0
494 except Exception as exc:
495 fut.set_exception(exc)
496 return
497
498 if n < count:
499 loop.add_writer(out_fd, self._sendfile_cb, fut, out_fd, in_fd,
500 offset + n, count - n, loop, True)
501 else:
502 fut.set_result(None)
503
504 @asyncio.coroutine
505 def _sendfile_system(self, req, resp, fobj, count):

Callers 4

_sendfile_systemMethod · 0.95

Calls 1

set_exceptionMethod · 0.45

Tested by 3