Best practice for variables shared between processes?

Daniel Pittman daniel at rimspace.net
Tue Sep 21 00:13:19 BST 2010


Mark Fowler <mark at twoshortplanks.com> writes:
> On 20 Sep 2010, at 17:30, Roger Burton West <roger at firedrake.org> wrote:
>
>> I wish to have two processes, a "producer" (which will create files) and a
>> "consumer" (which will do something with them), running simultaneously.
>> Ideally the producer would push filenames to a list as it finishes
>> producing them, while the consumer would shift them off the same list (or
>> loop-wait, if the list is empty).
>
> I had a better thought after my last post. Have one process create files
> and, when it's done with each file, atomically move them into a known
> directory for the second process to, um, process and delete then when done.

Just make sure it is a move, not a copy, of the file; at least one developer
around me has dropped in File::Copy::move when they got a plain rename refused
because it crossed devices — so ended up copying the data in anyway.

        Daniel

-- 
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons



More information about the london.pm mailing list