diff --git a/plugins/Trayicon/TrayiconPlugin.py b/plugins/Trayicon/TrayiconPlugin.py index a9254447..95ad4b50 100644 --- a/plugins/Trayicon/TrayiconPlugin.py +++ b/plugins/Trayicon/TrayiconPlugin.py @@ -1,4 +1,3 @@ -import time import os import sys import atexit @@ -12,6 +11,7 @@ allow_reload = False # No source reload supported in this plugin if "_" not in locals(): _ = Translate("plugins/Trayicon/languages/") + @PluginManager.registerTo("Actions") class ActionsPlugin(object): @@ -54,23 +54,26 @@ class ActionsPlugin(object): (_["ZeroNet Github"], lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet")), (_["Report bug/request feature"], lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet/issues")), "--", - (_["!Open ZeroNet"], lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage) )), + (_["!Open ZeroNet"], lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage))), "--", (_["Quit"], self.quit), ) - - icon.clicked = lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage) ) + icon.clicked = lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage)) + self.quit_servers_event = gevent.threadpool.ThreadResult( + lambda res: gevent.spawn_later(0.1, self.quitServers) + ) # Fix gevent thread switch error gevent.threadpool.start_new_thread(icon._run, ()) # Start in real thread (not gevent compatible) super(ActionsPlugin, self).main() icon._die = True def quit(self): self.icon.die() - time.sleep(0.1) - sys.exit() - # self.main.ui_server.stop() - # self.main.file_server.stop() + self.quit_servers_event.set(True) + + def quitServers(self): + self.main.ui_server.stop() + self.main.file_server.stop() def opensite(self, url): import webbrowser diff --git a/src/Config.py b/src/Config.py index 256f1857..ba7761b9 100644 --- a/src/Config.py +++ b/src/Config.py @@ -9,7 +9,7 @@ class Config(object): def __init__(self, argv): self.version = "0.5.1" - self.rev = 1816 + self.rev = 1817 self.argv = argv self.action = None self.config_file = "zeronet.conf"