Skip to content

Commit

Permalink
rebase and fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Nov 6, 2017
1 parent a6bf183 commit 87a5cfe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 5 additions & 4 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def set_transport(self, transport):
async def get_transport(self):
if self._transport is None:
if self._drain_waiter is None:
self._drain_waiter = create_future(self.loop)
self._drain_waiter = self.loop.create_future()
await self._drain_waiter
return self._transport

Expand Down Expand Up @@ -274,10 +274,11 @@ async def write_eof(self, chunk=b''):
self._transport = None
self._stream.release()

@asyncio.coroutine
def drain(self):
async def drain(self):
if self._transport is not None:
yield from self._stream.drain()
print(self._stream)
print(self._stream.drain)
await self._stream.drain()
else:
# wait for transport
await self.get_transport()
6 changes: 5 additions & 1 deletion tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ def stream(buf, transport):
stream = mock.Mock()
stream.transport = transport


def acquire(writer):
writer.set_transport(transport)
async def drain():
pass

stream.acquire.side_effect = acquire
stream.drain.return_value = ()
stream.drain.side_effect = drain

return stream


Expand Down
4 changes: 3 additions & 1 deletion tests/test_http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ def stream(transport):

def acquire(writer):
writer.set_transport(transport)
async def drain():
pass

stream.acquire = acquire
stream.drain.return_value = ()
stream.drain = drain
return stream


Expand Down

0 comments on commit 87a5cfe

Please sign in to comment.