Skip to content

Commit

Permalink
Close all websockets on plugin_unloaded (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste authored Feb 18, 2023
1 parent cd1a2d5 commit 69afa4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions GhostText.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ def plugin_unloaded():
return

GhostTextGlobals.http_status_server_thread.stop()
OnSelectionModifiedListener.unbind_all_views()
9 changes: 9 additions & 0 deletions GhostTextTools/OnSelectionModifiedListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def bind_view(view, web_socket_server):
print("Bind view with id: {}".format(view.id()))
OnSelectionModifiedListener._bind_views[view.id()] = web_socket_server

@classmethod
def unbind_all_views(cls):
"""
Close all websocket servers.
"""
for vid, server in cls._bind_views.items():
server.initiate_close()
cls._bind_views.clear()

@staticmethod
def unbind_view(view):
"""
Expand Down

0 comments on commit 69afa4e

Please sign in to comment.