Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Aug 8, 2017
1 parent 1e542cd commit e6a12c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ def get_transport(self):
if self._drain_waiter is None:
self._drain_waiter = create_future(self.loop)
yield from self._drain_waiter

assert self._transport is not None
return self._transport

@property
Expand Down Expand Up @@ -201,7 +199,6 @@ def _write(self, chunk):

# see set_transport: exactly one of _buffer or _transport is None
if self._transport is not None:
assert self._buffer is None
self._transport.write(chunk)
else:
self._buffer.append(chunk)
Expand Down
7 changes: 4 additions & 3 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
class SendfilePayloadWriter(PayloadWriter):

def __init__(self, *args, **kwargs):
self.__buffer = []
self._sendfile_buffer = []
super().__init__(*args, **kwargs)

def _write(self, chunk):
# we overwrite PayloadWriter._write, so nothing can be appended to
# _buffer, and nothing is written to the transport directly by the
# parent class
self.output_size += len(chunk)
self.__buffer.append(chunk)
self._sendfile_buffer.append(chunk)

def _sendfile_cb(self, fut, out_fd, in_fd,
offset, count, loop, registered):
Expand Down Expand Up @@ -65,8 +65,9 @@ def sendfile(self, fobj, count):
offset = fobj.tell()

loop = self.loop
data = b''.join(self._sendfile_buffer)
try:
yield from loop.sock_sendall(out_socket, b''.join(self.__buffer))
yield from loop.sock_sendall(out_socket, data)
fut = create_future(loop)
self._sendfile_cb(fut, out_fd, in_fd, offset, count, loop, False)
yield from fut
Expand Down

0 comments on commit e6a12c1

Please sign in to comment.