LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Isabelle Cabrera Date: Wed Jun 4 06:47:21 2008 Subject: Re: non blocking issue ?
`Zidane Tribal a écrit : > On 28/05/2008, Isabelle Cabrera <isabelle.cabrera@inria.fr> wrote: > >> 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 >> >> >> > > it sounds like each event is blocking, waiting for the computation to > return a result, and then releasing to allow EV to continue it's loop. > i have had a similar problem recently, (a multi-server irc bot), and > found i have a similar problem, each time the event was blocking and > waiting for a reply. > > how i solved it was to create a readable event for each socket, so > rather than send-wait-receive as you have, its send, then assign a > receive callback to trigger when a result is returned. thus, send > commands down each socket, and allow EV to loop until each one > returns, and as each result is returned, send another query, then let > EV wait on the result again, ad infinitum. > > i suspect this is a horribly confusing answer, and unfortunately i'm > away from home for a few days so i cant provide a code example, but > feel free to ask anything further. > > James Clark. > Thank you James. Finally my problem comes from the fact that my I/O interactions are blocking. So instead of using Net::Telnet I'm trying to use IO::Socket to do non blocking I/O. One other problem is that I had a huge callback, so I'm going to split up my code in smaller peaces. Best regards, Isabelle Cabrera -- Isabelle Cabrera Equipe-Projet Alpage - INRIA Paris-Rocquencourt http://alpage.inria.fr Tel : 01 3963 5270
| Navigate in group perl.loop at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |