diff options
author | liris <liris.pp@gmail.com> | 2018-10-28 10:43:17 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-28 10:43:17 +0900 |
commit | 0974399b9f7fa11accf66ae0db501ccd9ff86257 (patch) | |
tree | 8642ce8620223a54a71747de22597adbbb958e64 | |
parent | b54224fc87adcacb63a3822cfb4c1c66d0fc150d (diff) | |
parent | 85ca7b60235d49d44269f3b9bbc7af162a09feac (diff) | |
download | websocket-client-0974399b9f7fa11accf66ae0db501ccd9ff86257.tar.gz |
Merge pull request #480 from aarondav/fix_on_close
-rw-r--r-- | websocket/_app.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/websocket/_app.py b/websocket/_app.py index a05a2e3..81aa1fc 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -217,12 +217,16 @@ class WebSocketApp(object): if self.sock: raise WebSocketException("socket is already opened") thread = None - close_frame = None self.keep_running = True self.last_ping_tm = 0 self.last_pong_tm = 0 - def teardown(): + def teardown(close_frame=None): + """ + Tears down the connection. + If close_frame is set, we will invoke the on_close handler with the + statusCode and reason from there. + """ if thread and thread.isAlive(): event.set() thread.join() @@ -266,8 +270,7 @@ class WebSocketApp(object): op_code, frame = self.sock.recv_data_frame(True) if op_code == ABNF.OPCODE_CLOSE: - close_frame = frame - return teardown() + return teardown(frame) elif op_code == ABNF.OPCODE_PING: self._callback(self.on_ping, frame.data) elif op_code == ABNF.OPCODE_PONG: |