Problem with apsw and garbage collection

Nikolaus Rath Nikolaus at rath.org
Fri Jun 12 04:28:05 CEST 2009


Hi,

Please consider this example:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vacuum.py
Type: text/x-python
Size: 1006 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090611/2500f390/attachment.py>
-------------- next part --------------

While the first execute("VACUUM") call succeeds, the second does not but
raises an apsw.BusyError (meaning that sqlite thinks that it cannot get
an exclusive lock on the database).

I suspect that the reason for that is that the cursor object that is
created in the function is not destroyed when the function is left with
raise (rather than return), which in turn prevents sqlite from obtaining
the lock.

However, if I exchange the VACUUM command by something else (e.g. CREATE
TABLE), the program runs fine. I think this casts some doubt on the
above explanation, since, AFAIK sqlite always locks the entire file and
should therefore have the some problem as before.


Can someone explain what exactly is happening here?


Best,


   -Nikolaus

-- 
 ?Time flies like an arrow, fruit flies like a Banana.?

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C


More information about the Python-list mailing list