forked from LBRYCommunity/lbry-sdk
improve osx app shutdown
This commit is contained in:
parent
59c4593bf4
commit
3c977f961f
2 changed files with 14 additions and 5 deletions
|
@ -65,10 +65,14 @@ class LBRYDaemonApp(AppKit.NSApplication):
|
|||
def openui_(self, sender):
|
||||
webbrowser.open(settings.UI_ADDRESS)
|
||||
|
||||
def replyToApplicationShouldTerminate_(self, shouldTerminate):
|
||||
log.info('Shutting down')
|
||||
notify("Goodbye!")
|
||||
reactor.stop()
|
||||
# this code is from the example https://pythonhosted.org/pyobjc/examples/Cocoa/Twisted/WebServicesTool/index.html
|
||||
def applicationShouldTerminate_(self, sender):
|
||||
if reactor.running:
|
||||
log.info('Stopping twisted event loop')
|
||||
notify("Goodbye!")
|
||||
reactor.stop()
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def notify(msg):
|
||||
|
|
|
@ -18,9 +18,14 @@ def main():
|
|||
log_file = conf.settings.get_log_filename()
|
||||
log_support.configure_logging(log_file, console=True)
|
||||
app = LBRYDaemonApp.sharedApplication()
|
||||
reactor.addSystemEventTrigger("after", "shutdown", AppHelper.stopEventLoop)
|
||||
reactor.addSystemEventTrigger("after", "shutdown", shutdown)
|
||||
reactor.run()
|
||||
|
||||
|
||||
def shutdown():
|
||||
log.info('Stopping event loop')
|
||||
AppHelper.stopEventLoop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue