简体   繁体   English

Python的sqlite3模块中的timeout参数会影响正常事务的速度吗?

[英]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在Android手机上运行Python脚本(现在基本上已经死了)。 SL4A provides Python 2.6. SL4A提供了Python 2.6。

This script (along with some other processes) accesses an sqlite database using Python's built in sqlite3 module. 该脚本(以及一些其他进程)使用Python的内置sqlite3模块访问sqlite数据库。 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. 由于它在极低端的电话上运行,因此在进程之间的数据库写冲突时,会产生并发问题,从而导致频繁的OperationalError: database is locked异常。

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. 为了解决这个问题,我将sqlite3.connect调用中的timeout参数(请参阅此处的文档)从默认的5秒增加到20秒。 According to the docs, this will increase the time that sqlite waits before throwing the database is locked exception. 根据文档,这将增加sqlite在引发database is locked异常之前等待的时间。

My question is: will this increase in the timeout also affect the performance of other transactions, ie 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. 鉴于我工作的环境非常有限,我无法弄清楚如何客观地测试性能,因此这种看法可能是错误的。

仅当两个事务实际冲突时, 超时才重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM