non blocking issue ?

[email protected] (Isabelle Cabrera) Wed, 28 May 2008 17:48:24 +0200
Newsgroups perl.loop
Message-ID <[email protected]>
Hi,

I have a problem using the Event module.

My goal: I have several sentences that I need to parse. For a faster 
process, I have a dispatcher which sends the sentences to several hosts 
so that the processes are distributed.

In my dispatcher, I register every host. For each host I create a watcher :

    $self->{hosts}{$host}{watcher} =
    Event->var(desc =>"Process sentence on $host",
           var  => \$client->{free},
           poll => 'w',
           cb   => $self->next_dag($host),
           debug => 4,
    );

The callback next_dag is called every time all the process of parsing 
the sentence and sending back the results is done (more precisely when 
the host says it's ready to receive a new sentence, with variable 
$client->{free}).

Of course, I would like that every host can work at the same time 
(that's the point...), but my problem is that they do the job 
subsequently, one sentence at the time.

The created event mainly does the following:
- get the next sentence from a file
- send this sentence to the parser on the free host (through a server of 
parser accessed with Net::Telnet)
- get the result of the parsing (yes or no) (still through Net::Telnet...)
- if yes, connect again to the server of parser to generate one or 
several outputs and write them into one or several files
- says "I'm ready to get a new sentence to parse", triggering the 
variable 'free'

I thought that creating an event was automatically non blocking and 
several events could happen at the same time. Does the problem come from 
the I/O interactions ? If so, do I need to separate all these stages and 
watch for every I/O interactions ? And do I need to specify somewhere 
that I want non blocking I/O ?

Best regards,
Isabelle

-- 
Isabelle Cabrera
Projet Alpage - INRIA Rocquencourt
http://alpage.inria.fr
Tel : 01 3963 5270