Skip to content

Commit

Permalink
Fix: ClientResponse.close() is not a coroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton committed Jul 27, 2017
1 parent e610073 commit 1d3abd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 6 additions & 7 deletions aiodocker/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,16 +522,15 @@ async def run(self, **params):
self._transform_event,
human_bool(params['stream']),
)
async for data in self.json_stream:
await self.channel.publish(data)
try:
async for data in self.json_stream:
await self.channel.publish(data)
finally:
await self.json_stream.close()
self.json_stream = None
finally:
# signal termination to subscribers
await self.channel.publish(None)
try:
await self.json_stream.close()
except:
pass
self.json_stream = None

async def stop(self):
if self.json_stream is not None:
Expand Down
2 changes: 1 addition & 1 deletion aiodocker/jsonstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def close(self):
# (see https://github.com/KeepSafe/aiohttp/issues/739)

# response error , it has been closed
await self._response.close()
self._response.close()


async def json_stream_result(response, transform=None, stream=True):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,5 @@ async def test_events(docker, testing_images, event_loop):
break

assert events_occurred == ['create', 'start', 'kill', 'die', 'destroy']

await docker.events.stop()

0 comments on commit 1d3abd8

Please sign in to comment.