I’m new to Sublime plugins, and I’m trying to create a plugin that calls a function to create a socketserver. However, when I try to run the command from console it ends up crashing sublime, and I have to force-quit it. Is there any way to stop the crashing from happening? The server works fine when I build it in a separate file.
class AuthenticateCommand(sublime_plugin.TextCommand):
def run(self, edit, should_authenticate=False):
run_server()
class MyTCPHandler(socketserver.BaseRequestHandler):
def handle(self):
(put my handle code here)
def run_server():
HOST, PORT = "localhost", 8001
server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
print("Server created")
try:
print("Serving server")
server.handle_request()
server.server_close()
except:
server.server_close()
I noticed that if I called run_server from outside and reloaded the plugin with cmd-S, Sublime would crash but the server would be running after I reopened it again, so I’m a little confused. I’m currently using Sublime Text 3 on MacOSX.