#1 2011-06-20 15:43:32

edwinsn
Member
Registered: 2010-07-02
Posts: 1,217

How to compile the engine to be thread-safe?

Hi Arnaud,

You said that the synopsis sqlite engine is not compiled to be thread-safe, can I recompile it to be thread-safe?
You know, there are chances we need to access the database using other ways, for example, to access the DB from programs written in other language. In my specific case, I'll write some part of the app in Python, the only reason is that, that part will be cross-platform ready.

Thanks and have a nice day!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2011-06-20 17:44:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,492
Website

Re: How to compile the engine to be thread-safe?

I think you already asked this question in this forum:
http://synopse.info/forum/viewtopic.php?id=287

The answer didn't change!
(yet) wink

Because of the ORM layout, you should only use RESTful access, not direct access to the DB.

For instance, we need to have the cache updated.

So you would have to use RESTful access from Python.
Not difficult, since you can just use HTTP/1.1 and JSON natively in the Python library.

Offline

#3 2011-06-21 01:59:00

edwinsn
Member
Registered: 2010-07-02
Posts: 1,217

Re: How to compile the engine to be thread-safe?

Hi Arnaud,

Well, I understand, but in my specific case, the server will read data only and the client will write data only, so directly accessing to the DB is ok, and I want things to be simplified. Does your answer means that there is no way to re-compile the engine to be thread-safe?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2011-06-21 05:18:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,492
Website

Re: How to compile the engine to be thread-safe?

If you open the DB file from another process, it will still be able to access.

The current engine is compiled with define SQLITE_THREADSAFE = 2, that is assuming multi-thread safety is made by the caller.
But it's still process-safe, that is you will be able to safely access from another process.

So if your python library is able to handle the same file format as our ORM, I don't see any problem.
There will still be a file-level locking for writing.

Offline

Board footer

Powered by FluxBB