From the TurboGears FAQ. My comments injected in bold.
Why does my application work fine until it's idle for a while then the next request returns a "500 Internal Error" response?
Are you on mysql? If so, this is probably the mysql time out. Because cherrypy is a long running process it doesn't make a new connection on every page load. After a period of inactivity the mysql server will timeout the connection. This causes an error the next time the application attempts to use the connection. Why doesn't it attempt to reconnect before throwing an error?
One solution some people use is to set up a cron job that every so often wgets a page from the application that will cause a database query. There is also apparently a mysql wait_timeout setting that can be adjusted to stop the connection from timing out.
I noticed this Quirk/Bug on a TurboGears site I've been working on. This is really annoying.