Skip to content

Commit

Permalink
Add close method to websocket client
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohlool committed Feb 27, 2017
1 parent c85b8f5 commit 94861c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v1.0.1
- Bugfix: blocking exec call should remove channel metadata #140
- Add close method to websocket api of interactive exec #145

# v1.0.0b3
- Bugfix: Missing websocket-client dependency #131
Expand Down
1 change: 1 addition & 0 deletions examples/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@
resp.write_stdin("whoami\n")
user = resp.readline_stdout(timeout=3)
print("Server user is: %s" % user)
resp.close()
8 changes: 8 additions & 0 deletions kubernetes/client/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ def run_forever(self, timeout=None):
while self.is_open():
self.update(timeout=None)

def close(self, **kwargs):
"""
close websocket connection.
"""
self._connected = False
if self.sock:
self.sock.close(**kwargs)


WSResponse = collections.namedtuple('WSResponse', ['data'])

Expand Down

0 comments on commit 94861c7

Please sign in to comment.