Hi All,

I'm trying to write a function that only runs (automatically) every
two weeks that will just archive some rows in the database to another
table. So far this is what i have (which doesn't work, i get a
KeyError exception on the line were i try to do the select )

import web,threading,time

def archiver():
     while True:
          data = web.select('data',where='finish_data <= '14'))
          # do stuff with data
          #time.sleep(1209600), for testing purposes use 10 second
intervals
          time.sleep(10)


if __name__ == '__main__':

    web.config.db_parameters = dict(dbn='mysql', user='user',
pw='password', db='mydatabse')

    # start archiver thread
    archiver_thread =
threading.Thread(target=archiver,name='archiver_thread')
    archiver_thread.setDaemon(True)
    archiver_thread.start()

    web.run(urls, globals(), web.reloader)


Here is the traceback;

Exception in thread archiver_thread:
Traceback (most recent call last):
  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/threading.py", line 440, in run
    self.__target(*self.__args, **self.__kwargs)
  File "code.py", line 822, in archiver
    todos = web.select('data', where='finish_date <=
'14'',vars=locals())
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/db.py", line 551, in select
    if web.ctx.get('db_name') == "firebird":
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/utils.py", line 704, in __getattr__
    return getattr(self.__d[threading.currentThread()], attr)
KeyError: <Thread(archiver_thread, started daemon)>

I think the
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to