diff --git a/navpoint/about.py b/navpoint/about.py index b7ba151..4dbf22a 100644 --- a/navpoint/about.py +++ b/navpoint/about.py @@ -1,10 +1,19 @@ +import multiprocessing import webbrowser import threading +import asyncio +import signal +import time +import sys +import os import markdown import tornado.ioloop import tornado.web import navpoint.fix_path +def timed_exit(): + time.sleep(3) + os.kill(os.getpid(), signal.SIGTERM) class AboutHandler(tornado.web.RequestHandler): def get(self): @@ -44,19 +53,22 @@ class AboutHandler(tornado.web.RequestHandler): """ ) - tornado.ioloop.IOLoop.instance().stop() + threading.Thread(target=timed_exit).start() -def _run(): +async def _run(): app = tornado.web.Application( [ ("/", AboutHandler), ] ) app.listen(9999, address="127.0.0.1") - tornado.ioloop.IOLoop.instance().start() + await asyncio.Event().wait() + +def _wrapper(): + asyncio.run(_run()) def about(): - threading.Thread(target=_run).start() + multiprocessing.Process(target=_wrapper).start() webbrowser.open("http://127.0.0.1:9999/")