How to execute asynchronous post-processing in CherryPy?

人盡茶涼 提交于 2019-12-03 08:35:19

The "global threading aware queue" is called Queue.Queue. I just added a recipe for this at http://tools.cherrypy.org/wiki/BackgroundTaskQueue

As i was looking for this and it's now outdated, i found it useful to provide the correct (2012ish) answer. Simply add this at the beginning of the function that handles your url :

cherrypy.request.hooks.attach('on_end_request', mycallbackfunction)

There's more infos on hooks in the documentation but it's not very clear to me.

Martin v. Löwis

An on_end_request custom tool may be what you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!