I write/read a sqlite database in mutli-thread.
But sometimes there will have error as below when do session.flush()

(OperationalError) unable to open database file u'UPDATE downlist SET
state=?, last_updated=? WHERE downlist.id = ?' [2, '2008-03-09
00:47:28.142000', 2991]

I think had add lock so there should't flush at the same time (But
maybe one after another).
So why this happend and how to solve this problem?

Thanks.

some code example as below
______________________

import elixir
class DownHistory(object):
    db_lock=threading.RLock()

    def add(self,saver):
        if not self.has_url(saver.url):
            with self.db_lock:
                DownList(
                    url=saver.url,
                    saver=pickle.dumps(saver)
                ).save()
                elixir.session.flush()

    def pop(self):
        with self.db_lock:
 
down=DownList.query.filter_by(state=DownState.to_down).limit(1).all()
            if down:
                down=down[0]
                down.state=DownState.downing
                down.update()
                elixir.session.flush()
                return pickle.loads(str(down.saver))


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to