[Tutor] a bit off topic.. - more of a high level arch question!

bruce badouglas at gmail.com
Fri Oct 21 08:50:05 EDT 2016


Hi.

Thinking of a situation where I have two "processes" running. They
each want to operate on a list of files in the dir on a first come
first operate basis. Once a process finishes with the file, it deletes
it.

Only one process operates on a file.

I'm curious for ideas/thoughts.

As far as I can tell, using some sort of PID/Lock file is "the" way of
handling this.

ProcessA looks to see if the PIDFile is in use,
 If it is, I wait a "bit"
 if the PIDFile is "empty", I set it an proceed
   --when I finish my work, i reset the PIDFile


As long as both/all processes follow this logic,
 things should work, unless you get a "race" condition
 on the PIDFile..

Any thoughts on how you might handle this kind of situation, short of
having a master process, that forks/spawns of children, with the
master iterating through the list of files..

Thanks..


More information about the Tutor mailing list