Closed Patitotective closed 2 years ago
I ended up doing this
class PreviewMarkdownInBrowser(QObject):
def __init__(self, *args, **kwargs):
super().__init__()
self.args = args
self.kwargs = kwargs
self.app = None
self.hyperlink = None
self.server = None
def run(self):
self.app = grip.create_app(*self.args, **self.kwargs)
self.hyperlink = f"{self.app.config['HOST']}:{self.app.config['PORT']}"
self.server = multiprocessing.Process(target=lambda: self.app.run(open_browser=True))
self.server.start()
def stop(self):
self.server.terminate()
self.server.join()
I'm using grip to preview a markdown file in my application and I need to stop it from running. I have the below code inside a
QThread
and I'm not sure how to stop it.(Maybe
browser_thread.stop()
?)