Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Think about Loose Coupling

Re: How to tell a child what to do?

by Corion (Pope)
on Sep 21, 2005 at 09:12 UTC ( #493697=note: print w/ replies, xml ) Need Help??

in reply to How to tell a child what to do?

I would use a database as the communication mechanism. That way, you get easy and convenient control over the jobs, when they were started and when they were finished (or hanging). For the job description, you can either come up with a keyword mechanism or consider to put the actual code to be run into the database - this makes for convenient extensibility.

Comment on Re: How to tell a child what to do?
Re^2: How to tell a child what to do?
by Eyck (Priest) on Sep 21, 2005 at 10:17 UTC

    I'm sorry, but it seems like you're playing with databases and everything looks like a nail.

    Proposing additional and significant external dependencies for a nice self-contained program is not very smart.

      I'm sorry that I misunderstood your problem. I thought that your statement:

      The hard part seems to be communicating with children, with one child, I would probably use STDIN/STDOUT, servers like apache have symmetrical children, so I'm kind of lost as to what is the best way to do something like that.

      implied that your children are not symmetrical and maybe even distributed across machines, and that children die-ing from unknown reasons might be common.

      Maybe you should discuss the scope of your program in the original post to some larger extent - I found DBD::SQLite a very convenient, lightweight and self-contained database, for example.

        While I used DBD::SQLite in few projects and also found it to be convenient, lightweight, and relatively self-contained when it comes to databases, database is not a solution for communication problem. unless it is, but I just fail to see the reason to go through all the hassle of seting up a database

        Since all the communication is with my own children, setting up an external file ( be it SQLite, which I fail to see how would it be relevant, something lighter like DB_File, or even single file with locking, or even socket with external daemon ), seems a tiny little bit overblown, don't you think?

      You know it might actauly be a nail in some cases. It is odd that you ask a question and then are soo rude when you get an answer. Databases can be the right tool and they might not be. That depends entirely on your situation. If you wanted to have 100 children spread over 100 computers then a database would be a perfect solution. You said you wanted "possibly non-blocking and reliable way". Database is *one* of the answers that fits the question. For instances I work on windows and linux boxes and never feel comforatble with forking or "traditional" IPC. However I am always working with databases and most scripts I write use databases for something (not out of habit, i work with large sets of scheduling and accounting data in a database). In my case lots of times a DB is the easiest, fastest and most comfortable route for my problems. As far as we knew you where already connected to a DB and this would be a good solution.

      "Proposing additional and significant external dependencies for a nice self-contained program is not very smart." -- Considering we don't know the current dependencies of your program, we could hardly deduce that a database wouldn't fit your needs.

      Ask a question, get lots of answers, don't critise an answer or mock the person giving it just because it doesn't fit your need. We can't read your mind or know your particular needs or desires unless you tell us first. Sorry for the rant but its realy hurts to see someone try to help and provide a fair answer and be treated the way you tried corion.

      Eric Hodges

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2014-04-23 21:43 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (555 votes), past polls