Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: file reading / writing collisions

by simonodell (Acolyte)
on Sep 11, 2007 at 07:46 UTC ( [id://638248]=note: print w/replies, xml ) Need Help??


in reply to Re: file reading / writing collisions
in thread file reading / writing collisions

Thanks! just for the sake of curiosity, what happens now when a multiple file write occurs? I mean does the routine simply return 0 or does it wait for the file handle to be available and then write? is there some way to have the routine order a background write in the case of a locked file, so the rest of the script can carry on with what its doing.. or is that a bad idea??
  • Comment on Re^2: file reading / writing collisions

Replies are listed 'Best First'.
Re^3: file reading / writing collisions
by sgt (Deacon) on Sep 11, 2007 at 13:41 UTC

    Well you have to test for your system, but usually perl's flock will block, and you are right it's a problem as you might end up with too many processes! I prefer non-blocking handles and do the polling myself. 'perldoc -f fcntl' will tell you how to set up non-blocking flags.

    cheers --stephan
Re^3: file reading / writing collisions
by ikegami (Patriarch) on Sep 11, 2007 at 13:42 UTC

    flock: "it waits indefinitely until the lock is granted"

    I don't know of an easy to do what you want without polling. From the looks of it though, your locks are really short lived, so it should not be a problem.

    Update: s/should be/should not be/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found