mardi 26 avril 2016

Shared database manager process/object for library

I have a library which uses SQLite. Some of the consumers of this library use multiprocessing. SQLite has notorious problems with concurrency. Namely, many versions of it are compiled with whole-second sleep increments and thus there are a lot of timeout issues associated with programs that use multi-processing. This particular client application has this issue, and increasing the timeouts, as is suggested by the linked article and many other sources doesn't really solve the problem.

To solve this issue, I want to create a manager process which deals with all connections to the database in a serial fashion (or, perhaps not serial, but properly managed with locks in Python instead of at the SQLite level).

The scenario is as follows: client starts process, process loads library, eventually process tries to hit the sqlite database. At this point, library should start sqlite database manager (or connect to it, if the database manager process has already started).

My issue is this: I am unsure how to check to see if the database manager process has already started and connect to it if so. How can I create this type of interaction in within this library?

My only thought on this issue would be to do this through local network ports. This seems clunky and not particularly elegant.

Aucun commentaire:

Enregistrer un commentaire