Mas*_*far 18 python sqlite concurrency multithreading
为了充分利用并发性,SQLite3允许线程以三种方式访问同一连接:
有谁知道如何使用Python序列化连接.
Python具有"check_same_thread",允许在多线程和单线程之间切换; 但是,我无法知道如何将其序列化.
sqlite 页面http://www.sqlite.org/threadsafe.html说:“默认模式是序列化。” 您测试过并发现这不是真的吗?
编辑:
如果它不起作用,也许是 ctypes?我不知道这是否会对加载的 sqlite 模块产生任何影响。我想我有点怀疑事实并非如此;正如我想象的那样,该sqlite3_initialize()
函数可能在加载模块时被调用?或者也许只有当您创建数据库对象时?
http://www.sqlite.org/c3ref/config.html
>>> import sqlite3
>>> import ctypes
>>> from ctypes.util import find_library
>>> sqlite_lib = ctypes.CDLL(find_library('sqlite3'))
>>> sqlite_lib.sqlite3_config(3) # http://www.sqlite.org/c3ref/c_abort.html
0 # no error....
>>>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7265 次 |
最近记录: |