Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Sync item list between perl scripts, across servers (rename)

by tye (Sage)
on Nov 14, 2016 at 19:58 UTC ( #1175908=note: print w/replies, xml ) Need Help??


in reply to Sync item list between perl scripts, across servers

For each system, create a subdirectory for use just by that system. When a thread picks up a filename, use rename to perform an atomic move of that file into the subdirectory for the system that the thread is hosted on. If the rename fails, then just skip that filename as the other system beat you to it.

Even better, when rename() fails, compare $! against ENOENT() from Errno. If you are on a Unix system, than you can check "man 2 rename" on your particular system to verify that ENOENT is the appropriate choice (but if you are on a Unix system, then I'm pretty sure it will be).

In the unlikely event that you are not on a Unix system and are not using MS Windows, then Perl's rename might not be atomic.

- tye        

  • Comment on Re: Sync item list between perl scripts, across servers (rename)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1175908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-09-27 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (142 votes). Check out past polls.

    Notices?