Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: POE modules advice

by rcaputo (Chaplain)
on Mar 19, 2009 at 20:23 UTC ( #751862=note: print w/replies, xml ) Need Help??


in reply to POE modules advice

It sounds like you're putting the cart before the horse. POE::Wheel::Run includes parent/child process communication. POE::Component::Client::HTTP is not a a HTTP server. If your "clients" are simple programs, they could be implemented with plain LWP to talk to a POE-based HTTP server. You haven't explicitly said the httpd is running POE; I'm assuming yes because of the POE::Wheel::Run.

What I think (which is based on incomplete information and is probably wrong):

  • Plain old clients. LPW, curl, wget, whatever. This handles the client/httpd communication.
  • HTTP server, using one of the POE httpd components (your choice).
  • POE::Wheel::Run to run child processes and deal with httpd/child communication.
  • Worker pool management is a vague concept and probably includes some custom logic. Until I know more, you probably write this part.

I would have the child processes report their status as it changes, and then store that status in the HTTP session (not a POE session). When the client polls for status, it can be satisfied by the session information rather than asking the child process (which may have exited or crashed anyway).

http://poe.perl.org/?POE_Cookbook/Job_Server is a telnet based job server. It's not appropriate for your task, but it does show one way to write a server that accepts jobs and then runs them in separate processes.

Sorry for the vague answer. I may be able to narrow down my advice if you provide more specifics.

Replies are listed 'Best First'.
Re^2: POE modules advice
by Neid (Scribe) on Mar 19, 2009 at 21:45 UTC
    Yes that's true, httpd will be also POE (e.g. POE::Component::Server::HTTP ) I saw that POE::Wheel::Run uses stdin/stdout for communication.
    My workers is a perl code so I would pass subroutine reference to Wheel::Run 'Program' argument.
    Unfortunately that code may print some debug stuff.

    I was thinking about worker code as something similar to:

    sub worker{ my $self = shift; while( my $task = $some_queue->dequeue ) { # do_something() can print debug output to STDOUT my $result = $self->do_something(); my $status = { result => $result, time => time(), worker_id => + $self->id}; $self->update_status( $status); } }

    And parent code something like:
    sub parent { my $self = shift; $some_queue->enqueue( $new_task); } sub update_status_event{ my $status = shift; # do something with status #... }

    So I think POE::Wheel::Run for inter-process communication is not enough.
    Any advice here?

    Thanks,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2022-10-02 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (7 votes). Check out past polls.

    Notices?