Hey Alex,
As I said. My class is specifically written as a cakephp datasource
and cannot be used standalone.
Anyway, this is the interesting part. Perhaps you could use this as an
example to implement it yourself:
/* Reserve a msg (non-blocking by default) */
function reserve($block=false) {
$mode=($block)?'reserve':'reserve-with-timeout 1';
$this->send_data($mode);
if ($block) {
$l = 0;
while($l==0) {
if ($this->alive()) {
$r = array('socket'=>$this->socket);
$l = stream_select($r, $w=null,
$e=null, 10);
} else {
return false;
}
}
}
if ($this->check_reply(array(
'/RESERVED (\d+) (\d+)/' => true,
'/TIMED_OUT/' => false,
'/DEADLINE_SOON/' => false
))) {
$this->id = $this->regs[0];
$bytes = $this->regs[1];
$this->body = $this->read_data($bytes);
return true;
}
return false;
}
Best regards,
Dennis Krul
On Dec 2, 10:23 am, Alexander Kunz <[email protected]> wrote:
> Hello Dennis,
>
> thanks for you solution. I have the same problem some weeks ago, and
> found no answer. I am also
> interested in a working beanstalk php class. I will try stream_select()
> next week. perhaps you or mike
> can share the working beanstalk php class?
>
> Have a nice day. Kind regards
>
> Alexander
>
> Dennis Krul wrote:
> > Hey Mike,
>
> > I don't use the beanstalk php class, but I used it as a reference to
> > implement my own one as a datasource for cakephp some time ago and I had
> > the same issue.
>
> > The trick is to use stream_select() to wait for data on the socket before
> > reading from the socket. You need to hack that into the reserve function
> > somewhere. I'm actually a bit surprised this hasn't been fixed in the
> > 'official' beanstalk php class yet. Perhaps no-one actually uses it except
> > you and me :)
>
> > Good luck
>
>
--
You received this message because you are subscribed to the Google Groups
"beanstalk-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/beanstalk-talk?hl=en.