Python 3.3 changed the way how the daemon mode is initialized on threads. There is a now a constructor argument daemon that is used to set the mode and not anymore the setdaemon() function.
I changed the BackgroundTask constructor to set the daemon mode more explicit.
Without this patch in Python 3.3 the shutdown of cherrypy takes up to the frequency interval of the Monitor class to shutdown.
Tested on Python 3.2 and 3.3
Hi Rene. Thanks for the contrib. This does sound like something we want to fix. However, I believe your patch is not compatible with Python 2.3-2.7 (which CherryPy also supports). I suspect you may need to add some compatibility shim (see _cpcompat for all the hoops that CherryPy jumps through to maintain a single code base on Python 2+3) to restore the desired behavior.
After further consideration, I don't see the value in adding to the constructor interface of BackgroundTask. Additionally, that 'daemon' parameter won't be honored on Python 2.5 or earlier (it will be set on the class, but not used by the superclass). Not to worry though. I appreciate the effort. I'll pull your changes and adapt them to something that achieves the same goals. Thanks again for bringing this to light.
I've repaired the cherrypy-3.2.x branch (it no longer has recent ancestors in the default branch). I've also pushed an alternative approach that doesn't alter the BackgroundTask constructor interface, and should set the thread to daemonic on all supported Pythons.