Greetings,
In my CherryPy-based app, I'm having regular problems with
the
CherryPy server not shutting itself down cleanly. Pressing
Control-C
repeatedly does nothing, and the only way to stop the server
is to do
a "kill -s 9 <pid>" from another terminal
window.
This doesn't happen all the time, but it's regular enough to
be a real
nuisance. It probably happens 50% of the time, especially
after
accessing a particularly ajax-heavy page which does a lot of
back-and-
forth between the Javascript code and the CherryPy-based
page
handler. Pretty much every time I go to that page, the
CherryPy
server will be unable to shut down cleanly.
I don't really know how CherryPy handles a shutdown
internally, so I'm
not having much luck tracing this problem. I'm running
CherryPy
version 3.0.1 on a MacBook Pro running OSX 10.4.7 with
Python version
2.5, if any of that is relevant.
Here are the app config settings I'm passing to
cherrypy.tree.mount():
log.screen : False
log.error_file : "temp/logs/error.log"
log.access_file : "temp/logs/access.log"
tools.log_tracebacks.on : True
tools.staticdir.root : os.path.abspath(".")
server.socket_host : ""
server.socket_port : 8080
server.thread_pool : 10
request.show_tracebacks : True
engine.autoreload.on : True
And here are the site config settings I'm passing to
cherrypy.config.update():
siteConfig = {
'/toolkit/resources' :
{'tools.staticdir.on' : True,
'tools.staticdir.dir' :
"toolkit/resources",
},
'/resources' :
{'tools.staticdir.on' : True,
'tools.staticdir.dir' :
"app/resources",
},
}
[despite the note at cherrypy.org/wiki/ConfigFile about
being able to
mix the two sets of configuration settings, I wasn't able to
get this
working, so I've kept them separate].
Again, I don't know if any of this is relevant, but I
figured I'd
include it just for completeness.
###########
Now, I've written some code which peeks into the python
process and
scans all the open threads, periodically writing a stack
trace for
each open thread to a file. I can see various
CherryPy-related
threads doing their thing as usual, and when I try
(unsuccessfully) to
shut down the application by pressing Control-C, it leaves
the
following two threads which never stop:
Thread 27963904:
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 460, in __bootstrap
self.run()
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/cherrypy/_cpengine.py", line
24, in run
self.finished.wait(self.interval)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 364, in wait
self.__cond.wait(timeout)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 233, in wait
_sleep(delay)
Thread -1610559648:
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 652, in __exitfunc
t.join()
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 558, in join
self.__block.wait()
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/threading.py", line 214, in wait
waiter.acquire()
Based on my (very rough) understanding of how CherryPy
works
internally, it looks as though the CherryPy engine never
finishes
shutting down -- there's a monitor thread (a PerpetualTimer
object)
which is never cancelled, preventing the app from shutting
down.
If anyone can see anything I've done wrong in my
configuration
settings, or if you have any suggestions for how I can trace
this
problem down, I'd be very grateful. I'm kind of stuck at
the
moment...
Thanks,
- Erik.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|