Dirkjan Bussink wrote:
On Thu, Nov 6, 2008 at 11:17 PM, Earle Clubb <[EMAIL PROTECTED]> wrote:
  
sqlite3 can only handle one write at a time.  It raises the locked exception when another thread or process has an exclusive lock on the db.  I got around this by putting a wrapper around the lowest-level query methods which will retry up to 4 times before passing the exception up the stack.  Here's my code, which I placed in the same file as my model definitions:
    

Well, trying again is not guaranteed to be safe in all conditions. The
only way to properly handle this is using a Mutex object to guarantee
that only one query accesses sqlite3 at the same time. This probably
should be handled at the do_sqlite3 level.

To the original poster, if you really want queries to be run in
parallel, you should use a full fledged RDMS like PostgreSQL or MySQL.

  
You're right that it's not guaranteed to be safe, but I think it's the best you can do with sqlite3.  Using a mutex would help within the same process (and maybe between ruby processes), but I don't see a way to do that between say, ruby, php, and c processes.


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

Reply via email to