擅长:python、mysql、java
<p>您需要编写停止线程的代码,并将其注册为“stop”事件的侦听器:</p>
<pre><code>from cherrypy.process import plugins
class MyFeature(plugins.SimplePlugin):
"""A feature that does something."""
def start(self):
self.bus.log("Starting my feature")
self.threads = mylib.start_new_threads()
def stop(self):
self.bus.log("Stopping my feature.")
for t in self.threads:
mylib.stop_thread(t)
t.join()
my_feature = MyFeature(cherrypy.engine)
my_feature.subscribe()
</code></pre>
<p>有关详细信息,请参见<a href="http://www.cherrypy.org/wiki/BuiltinPlugins" rel="noreferrer">http://www.cherrypy.org/wiki/BuiltinPlugins</a>和<a href="http://www.cherrypy.org/wiki/CustomPlugins" rel="noreferrer">http://www.cherrypy.org/wiki/CustomPlugins</a>。在</p>