python-3.x - 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
处理程序标记为作为守护线程运行,以便在主线程停止后立即停止整个应用程序?
解决方案
推荐阅读
- schema.org - 捆绑或分组产品的正确标记是什么
- r - R中的clusterApply()和parApply()有什么区别?
- gitversion - 如何告诉 Gitversion 如何从分支名称解析版本?
- r - 使用 shinyapps.io 并重新连接到主机 .Rmd 报告时遇到问题
- php - LEFT JOIN 同一张表的多行 | SQL 服务器 2012
- airflow - 从 Airflow 中清除的任务中获取 XCom
- ios - 使用 NSPersistentCloudKitContainer 保持关系
- ios - 每当我使用 geofire 给线程时,应用程序就会崩溃!: SIGABRT 错误
- haskell - f, g, h :: Kleisli ((->) e) ab <=> f >>> (g &&& h) = (f >>> g) &&& (f >>> h)?
- html - HTML -- margin-left & -right 不适用于 flexbox