Search code examples
androidpythonsqlitesl4a

Does the timeout parameter in Python's sqlite3 module affect the speed of normal transactions?


I am running a Python script on an Android phone using SL4A (sadly now basically dead). SL4A provides Python 2.6.

This script (along with some other processes) accesses an sqlite database using Python's built in sqlite3 module. As it is running on an extremely low end phone, this is creating concurrency problems as database writes between processes are clashing, resulting in frequent OperationalError: database is locked exceptions.

To deal with this, I've increased the timeout parameter in the sqlite3.connect call (see here for the documentation) to 20 seconds from the default 5 seconds. According to the docs, this will increase the time that sqlite waits before throwing the database is locked exception.

My question is: will this increase in the timeout also affect the performance of other transactions, i.e. those that are not blocked by another process? Or is this only a timeout for this purpose alone?

I'm concerned because there seems to be a drop in performance after I changed this parameter. Given the very limited environment I'm working in, I haven't been able to figure out how to objectively test performance, so this perception might be wrong.


Solution

  • The timeout matters only if two transactions actually conflict.