baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
i need an advice on how to band all types of threading forking or any kind of paralelization of my perl program. The program uses DBI to communicate with SQLite db to read and write in it. so the other day it came to me:
could i speed up my work by forking my program, give him different data to process ...
result was :
working,working,working, crash !!!!! Why -> because it came to the step where it needed to write something into the database-locked db (totally forgot that it is using databases :))
so, because i really can't remember what else could crash and am to lazy to go through whole script, i was wondering could i prevent anyone(my future self) that will ever (if ever) use this software to fork it in souch a way that if the program is already running in one location, that it cannot be started again in that location(on disc), but if the user needs to he can move the program to another location an then paralelize its work by forking for example.(why another location -> because the db's are formed in the same path where the program is ./db.db)
My idea was to create a temp file and write a flag in it, so the next time the program is started it will first check for that file and if the file is there it will exit and if it is not it means that the program is not started. and when the program exits it will delete that file. the problem is what if the exit was forced what then ... the program is not running and it will not be possible to start it because of the file(it will stay there because of the forced exit)
i hope i was clear enough in this essay of mine:)
thnx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: disable possible threads
by perreal (Monk) on Jun 15, 2009 at 13:14 UTC | |
by baxy77bax (Deacon) on Jun 15, 2009 at 17:47 UTC | |
by perreal (Monk) on Jun 15, 2009 at 19:41 UTC | |
|
Try this.
by maria66 (Initiate) on Jun 18, 2009 at 07:32 UTC |