librelist archives

« back to archive

Simpler way to run the tasks

Simpler way to run the tasks

From:
Loic d'Anterroches
Date:
2011-12-16 @ 08:38
Hello,

at the moment, the "runner" is either sync or async and in sync mode,
this is a REQ/REP pattern without timeout.

What I propose is:

1- to allow a task worker to be available on several ZMQ end points. The
Photon process will use only one socket to connect to all the end points
of the worker.

2- use a poll to read the answers, this way instead of doing a run() and
directly waiting for the answers, the run will not read the answers. It
will push the answers and you will have to read($timeout) to get the
results. This also means that the results will be an array as you will
be able to run() several times before read().

So, if you do
$runner->run(...);
$runner->run(...);
$runner->run(...);
You get
list($res1, $res2, $res3) = $runner->read($timeout);

one of the $resX can be null if the timeout was reached.

I am going to test this in the next few weeks before setting everything
in stones.

loïc

--
Indefero - Project management and code hosting - http://www.indefero.net
Photon - High Performance PHP Framework - http://photon-project.com
Céondo Ltd - Web + Science = Fun - http://www.ceondo.com

Re: [photon.users] Simpler way to run the tasks

From:
William Martin
Date:
2011-12-16 @ 08:50
Hi loic,

We must have a timeout on the runner, because if a sync task don't
answer (bug, crash, ip packet dropped, ....), the worker will be
locked in waiting an answer.

William

On Fri, Dec 16, 2011 at 9:38 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
> at the moment, the "runner" is either sync or async and in sync mode,
> this is a REQ/REP pattern without timeout.
>
> What I propose is:
>
> 1- to allow a task worker to be available on several ZMQ end points. The
> Photon process will use only one socket to connect to all the end points
> of the worker.
>
> 2- use a poll to read the answers, this way instead of doing a run() and
> directly waiting for the answers, the run will not read the answers. It
> will push he answers and you will have to read($timeout) to get the
> results. This also means that the results will be an array as you will
> be able to run() several times before read().
>
> So, if you do
> $runner->run(...);
> $runner->run(...);
> $runner->run(...);
> You get
> list($res1, $res2, $res3) = $runner->read($timeout);
>
> one of the $resX can be null if the timeout was reached.
>
> I am going to test this in the next few weeks before setting everything
> in stones.
>
> loïc
>
> --
> Indefero - Project management and code hosting - http://www.indefero.net
> Photon - High Performance PHP Framework - http://photon-project.com
> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Simpler way to run the tasks

From:
Loic d'Anterroches
Date:
2011-12-16 @ 08:50

On 2011-12-16 09:50, William MARTIN wrote:
> Hi loic,
> 
> We must have a timeout on the runner, because if a sync task don't
> answer (bug, crash, ip packet dropped, ....), the worker will be
> locked in waiting an answer.

Yes, exactly.

loïc

> On Fri, Dec 16, 2011 at 9:38 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
>> Hello,
>>
>> at the moment, the "runner" is either sync or async and in sync mode,
>> this is a REQ/REP pattern without timeout.
>>
>> What I propose is:
>>
>> 1- to allow a task worker to be available on several ZMQ end points. The
>> Photon process will use only one socket to connect to all the end points
>> of the worker.
>>
>> 2- use a poll to read the answers, this way instead of doing a run() and
>> directly waiting for the answers, the run will not read the answers. It
>> will push he answers and you will have to read($timeout) to get the
>> results. This also means that the results will be an array as you will
>> be able to run() several times before read().
>>
>> So, if you do
>> $runner->run(...);
>> $runner->run(...);
>> $runner->run(...);
>> You get
>> list($res1, $res2, $res3) = $runner->read($timeout);
>>
>> one of the $resX can be null if the timeout was reached.
>>
>> I am going to test this in the next few weeks before setting everything
>> in stones.
>>
>> loïc
>>
>> --
>> Indefero - Project management and code hosting - http://www.indefero.net
>> Photon - High Performance PHP Framework - http://photon-project.com
>> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
> 
> 
> 

-- 
Dr Loïc d'Anterroches
Founder Céondo Ltd

w: www.ceondo.com       |  e: loic@ceondo.com
t: +44 (0)207 183 0016  |  f: +44 (0)207 183 0124

Céondo Ltd
Dalton House
60 Windsor Avenue
London
SW19 2RR / United Kingdom