List Info

Thread: Making a page from a list - puzzle




Making a page from a list - puzzle
country flaguser name
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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.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
country flaguser name
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
fumanchuamor.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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.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
user name
2007-05-21 13:56:07


On 5/21/07, fumanchu < fumanchuamor.org">fumanchuamor.org&gt; wrote:

On May 21, 12:01 am, gv < sgven...googlemail.com">sgven...googlemail.com> wrote:
>; I have a home page that is intended to be populated from SQL every 120
> seconds as below.&nbsp; &nbsp; It works too, except after a few hours it stops
&gt; working as intended.&nbsp; 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

&quot;After a period of inactivity the mysql server will timeout the
connection."

Thanks, but I don't think this is it, because other parts of the site that use the same connection keep on working, and  anyway there isn't a period of inactivity of more than 120 seconds.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users&quot; group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to cherrypy-users-unsubscribegooglegroups.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
country flaguser name
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
fumanchuamor.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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.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
country flaguser name
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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.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 )