In my application I have 3 sub application scripts, one of them has an option to optimize the database.
This task can only succeed if only the one application script is running.
Could I use (or abuse) SingleInstanceChecker for this? I.e. could I have:
SICInstance1, SICInstance2, and SICInstance3 and e.g. in before running the db optimize check that the others e.g. 2 and 3 are not running?
If it matters, all three use the same wx.App.OnInit code to start up, so would it be enough if each of them set a variable which is used to generate the "app name" which is passed into SingleInstanceChecker.
Are there things which will bite me with this approach?
Say, someone running the optimizations manually from
elsewhere.
It seems advisable to put the lock as close to the
thing-to-lock as possible. Say, a lock inside the database.
Or else (say, if you are dealing with sqlite) rename the
database (file), optimize it, put it back.
Karsten
···
On Thu, Feb 21, 2013 at 01:31:44PM +0100, Werner wrote:
Are there things which will bite me with this approach?
Are there things which will bite me with this approach?
Most definitely, Something no one thought of.
Say, someone running the optimizations manually from
elsewhere.
Within the application there is only one place where one can run the optimization. Should they use a db tool for Firebird SQL to manually do the optimization, very unlikely as my "normal" user does not have/know these tools, but at that point I would have no control over it - at least none I can think of.
It seems advisable to put the lock as close to the
thing-to-lock as possible.
Come to think of it I am not even sure I need anything else, as a first step in the optimization process I check that there is just this one connection, and only then do I proceed to optimize to a new database file and when it is all done I move the old one away and put the optimized one in its place.
Thanks for making me think some more about all this:-) .
Werner
···
On 21/02/2013 17:46, Karsten Hilbert wrote:
On Thu, Feb 21, 2013 at 01:31:44PM +0100, Werner wrote: