docker/docker-py — pull request #336 by leth (2014-10-03 20:59:47+00:00)
Title: Rescue buffered data before consuming from stream

I managed to [track down a hang when calling `build()`](https://groups.google.com/forum/#!topic/docker-dev/fhrTqwF7IJQ) to a problem handling streams.

`strace` proved that the problem was somewhere in the python client and I manage to create a test harness for this issue.

This is not the most elegant fix, I could do with some advice:
* I've changed the return value of attach_socket
* In _stream_helper it creates a new fileobj, when we just threw away the one which had our data buffer in it, we could just keep the old one.