Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: while reading a file, transfer the same data to two different processes.

by avanta (Beadle)
on May 20, 2010 at 15:49 UTC ( [id://840968]=note: print w/replies, xml ) Need Help??


in reply to Re: while reading a file, transfer the same data to two different processes.
in thread while reading a file, transfer the same data to two different processes.

I need to "fork" because I dont want any interference of the two functions. i.e. if "function1" crashes it should not affect "funtion2". To put it this way, my "function1" is in the current script from where I am running the process and "function2" is collection of different procesing steps which may be huge so if "function1" dies due to some reason the whole process will crash and "function2" will die along with it, and I dont wish to have a scene like this. I wish to have "function2" continue.

Replies are listed 'Best First'.
Re^3: while reading a file, transfer the same data to two different processes.
by JavaFan (Canon) on May 20, 2010 at 15:55 UTC
    But the other way is fine? That is, function1 may crash and take with it the entire process?

    What you could do is for each line, fork twice. First child calls function1, second child calls function2. Both children exit afterwards. Parent waits till children are done before reading the next batch. Then the process will not be stopped if either function crashes on a batch.

      But here "function1" and "function2" are not processing just for every record. they are processing first record and then join the results to second record after processing and so on...so in short i cannot kill the process while returning to start of the loop.
        Then your setup is flawed. You do not want to fork in each iteration.

        Why not fork before opening the file, and have each subprocess iterate over the file and process it? Or just write two programs?

        Of course, if there even more non-obvious requirements, list them first ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-03-19 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found