mirror of
https://github.com/ha7ilm/openwebrx.git
synced 2026-04-21 06:13:45 +00:00
improve shutdown handling
This commit is contained in:
parent
17a362fe7a
commit
a85a6c694c
6 changed files with 58 additions and 31 deletions
|
|
@ -72,5 +72,20 @@ class WebSocketConnection(object):
|
|||
else:
|
||||
logger.warning("unsupported opcode: {0}".format(opcode))
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
header = self.get_header(0, 8)
|
||||
self.handler.wfile.write(header)
|
||||
self.handler.wfile.flush()
|
||||
except ValueError:
|
||||
logger.exception("while writing close frame:")
|
||||
|
||||
try:
|
||||
self.handler.finish()
|
||||
self.handler.connection.close()
|
||||
except Exception:
|
||||
logger.exception("while closing connection:")
|
||||
|
||||
|
||||
class WebSocketException(Exception):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue