首页 > 解决方案 > cherrypy 标记要作为守护线程运行的处理程序?

问题描述

我有以下樱桃应用程序:

class Hqyc:
    @cherrypy.expose
    def index(self):
        with open('index.html', 'r') as content_file:
            html_content = content_file.read()
        return html_content

    @cherrypy.expose
    def long_running(self):
        # do some long running computation in background

现在,当我点击Ctrl+C终止主线程时,应用程序将等待子线程停止,并且可能需要很长时间。如何将long_running处理程序标记为作为守护线程运行,以便在主线程停止后立即停止整个应用程序?

标签: python-3.xmultithreadingcherrypy

解决方案


推荐阅读