|
List Info
Thread: Making a page from a list - puzzle
|
|
| Making a page from a list - puzzle |
  United States |
2007-05-21 02:01:26 |
Hello
I have a home page that is intended to be populated from SQL
every 120
seconds as below. It works too, except after a few hours
it stops
working as intended. That is, it keeps serving a page that
doesn't
reflect new changes in SQL.
def daemon():
while 1:
global mylist
mylist = ---populate from SQL
#do other things
time.sleep(120)
class Head:
#define stuff common to most pages
class Page(Head):
def index
#make page from mylist
thread.start_new_thread(daemon,())
cherrypy.server.quickstart()
cherrypy.engine.start()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Making a page from a list - puzzle |
  United States |
2007-05-21 13:25:14 |
On May 21, 12:01 am, gv <sgven... googlemail.com> wrote:
> I have a home page that is intended to be populated
from SQL every 120
> seconds as below. It works too, except after a few
hours it stops
> working as intended. That is, it keeps serving a page
that doesn't
> reflect new changes in SQL.
If you're using MySQL, see http:/
/docs.turbogears.org/FAQ#troubleshooting
"After a period of inactivity the mysql server will
timeout the
connection."
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Making a page from a list - puzzle |

|
2007-05-21 13:56:07 |
|
--~--~---------~--~----~------------~-------~--~----~
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 http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: Making a page from a list - puzzle |
  United States |
2007-05-21 15:41:28 |
gv wrote:
> I have a home page that is intended to be populated
from SQL every 120
> seconds as below. It works too, except after a few
hours it stops
> working as intended. That is, it keeps serving a page
that doesn't
> reflect new changes in SQL.
>
>
> def daemon():
> while 1:
> global mylist
> mylist = ---populate from SQL
> #do other things
> time.sleep(120)
>
> class Head:
> #define stuff common to most pages
>
> class Page(Head):
>
> def index
> #make page from mylist
>
> thread.start_new_thread(daemon,())
> cherrypy.server.quickstart()
> cherrypy.engine.start()
There's not much to say until you find out what's failing.
Wrap the
daemon method in a log, at least:
import sys, traceback
def daemon():
try:
while 1:
global mylist
mylist = ---populate from SQL
#do other things
time.sleep(120)
except:
f = open('mylist.log', 'wb')
f.write("".join(traceback.format_exception(*sys.ex
c_info())))
f.close()
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Making a page from a list - puzzle |
  United States |
2007-05-23 01:47:19 |
Hi,
Try using DBUtils : persistent (also pooled) database
connections that
reconnect in case of time-out. Usage from their pages:
import pgdb # import used DB-API 2 module #works for mysql
as well
with the right import
from DBUtils.PersistentDB import PersistentDB
persist = PersistentDB(pgdb, 1000, database='mydb')
Once you have set up the generator with these parameters,
you can
request database connections of that kind:
db = persist.connection()
...
Read more on http://www.webwareforpython.org/DBUtils
/Docs/UsersGuide.html#persistentdb
. In addition, it is not a bad idea to use try .. except..
BR, Alex
http://sourc
eforge.net/projects/cubulus/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|