-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuring STREAM_SELECT_USEC #18
Comments
@rbro Thanks for the issue. First of all: Congratulations, you spotted a bug. 🎉 The value of Can you please open another issue for that and provide a simple PR which changes that value? I quickly looked where I could add a custom value for Option 1Configure it via Option 2Introduce a new optional parameter to the following methods:
This would introduce quite a lot of complexity and harms the readability of the current lib API, IMO. Option 3Introduce a new getter/setter in the request classes for the wait-time and add it to the internal socket instance, so each socket can have a custom wait-time for But that means that it just applies to Long story short:None of the 3 options is a good / flexible solution in my opinion. Furthermore they add complexity and maybe even a BC break for a use-case which can be solved by one line of user-land code: <?php
while (true)
{
if ($client->hasResponse($requestId))
{
$client->handleResponse($requestId);
break;
}
usleep(500000); # Wait half a second
// do other work here
} If no one else has strong arguments against it or better solutions, I'd close and label this issue as |
@hollodotme - thanks, I'll submit a PR soon. I'll think through possible options too, but I'm doing now what you wrote at the end with usleep, but it has a side effect and is why I noticed the issue above. My message queue processing times were a lot slower than what they should have been when processing say 1,000's of messages. I was losing up to half a second for each message I was processing from rabbitmq because if the fastcgi server returned while usleep was running, the script would have to wait for usleep to finish before calling stream_select again. It would be much more efficient to have that waiting be done in the call to stream_select because then the response from the fastcgi server will be processed as soon as it comes in rather than waiting for usleep to finish. |
@rbro Well, that is a valid point. 👍 I am currently in the middle of organizing a PHP conference which happens next weekend, so I have little time to do some prototyping and testing during the next 2 weeks. But I'll surely try to wrap my head around it and find a proper solution. Any input is welcome in the meanwhile. 😄 |
Hello,
I am making an async request, and while waiting for the response, I want to do other work. In my case, it's calling a check heartbeat function in rabbitmq, so I don't lose the connection while my request is processing - related to what I wrote at the bottom of #6. I am using a pattern like:
What I noticed is that in hasResponse, Socket::STREAM_SELECT_USEC is 20000 microseconds, which is a little quick for what I need. I would prefer to wait a little longer each iteration as the check heartbeat function doesn't need to run that often.
Would it be possible to allow the user to change STREAM_SELECT_USEC to be another value? Right now it's a constant, so it can't be changed.
Thanks again for your help.
The text was updated successfully, but these errors were encountered: