thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Souvik Roy <da.comp....@gmail.com>
Subject Re: "oneway" doesn't seem to work with PHP
Date Thu, 17 Mar 2011 20:30:49 GMT
Thanks for the reply Bryan. I did search JIRA, but no such bugs have been
reported yet.
I took a closer look into the functionality and found out something which I
wasn't expecting.
It seems as though subsequent "oneway" calls block each other and happen in
a synchronized fashion - the first call does happen asynchronously and out
of order though !
Consider the following code (based on the previous code snippet);

//Server snippet
*public function test($test_bigint){
echo 'before sleep '. $test_bigint;
sleep(10);
echo 'after sleep '. $test_bigint;
}*

If I call the above as:
*echo "Start";
$client->test(1);
echo "Done";
$client->test(2);*

The output of the above is:
*Start
Done
before sleep1
after sleep1
before sleep2
after sleep2*

I wonder if this was "meant to be" this way? All I'm trying is to execute a
method multiple times, in parallel. This can be achieved with threads in
other languages, but I was wondering if "oneway" methods can help me in PHP
here.

Cheers!

On Thu, Mar 17, 2011 at 10:13 PM, Bryan Duxbury <bryan@rapleaf.com> wrote:
> Sounds like a bug to me. I'm not aware of any existing issue, but you
might
> want to do a search in our JIRA.
>
> On Thu, Mar 17, 2011 at 8:59 AM, Souvik Roy <da.comp.guy@gmail.com> wrote:
>
>> Hi
>> I'm aware that PHP doesn't have threading support yet, hence a
>> MultiThreaded thrift server is not possible with Thrift in PHP
>> (right?). But I was under an impression than "oneway" asynchronous
>> functions do work with Thrift - PHP:server. But that doesn't seem to
>> be the case. To reproduce it, I wrote a small function defined as
>> follows:
>>
>> //Server snippet
>> public function test($test_bigint){
>> echo 'before sleep '. $test_bigint;
>> sleep(10);
>> echo 'after sleep '. $test_bigint;
>> }
>>
>> //Client snippet
>> for($i=0;$i<10;$i++){
>>    $client->test($i);
>>  }
>>
>> //Thrift IDL
>> service someservice{
>> oneway void test(1:i64 test_bigint)
>> }
>>
>> Ideally, the above should be executed asynchronously and should not
>> wait for the function to finish execution (and print "before sleep"$i
>> all through the iterated times at first). But the actual output waits
>> for sleep(10) and is executed synchronously.
>> Is this a known feature Bug? If this topic has been already discussed
>> earlier, can anyone please point me to the thread URL ?
>>
>> Thanks
>> --
>> Souvik Roy
>> http://www.souvikroy.com
>>
>



-- 
Souvik Roy
http://www.souvikroy.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message