Skip to content

PHP Warning when interupting consumer with a signal. #165

@Stubbs

Description

@Stubbs
Warning: stream_select(): unable to select [4]: Interrupted system call (max_fd=7) in /Users/stu/Dropbox/im_british_so_i_know_how_to_queue/src/chapter5/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php on line 103

If you add a signal handler, when a signal is caught this warning is output.

I've changed the basic wait loop to look like this:

    while (count($channel->callbacks) && $this->continue) {
        try {
            $channel->wait(null, false, 1);
        } catch (\PhpAmqpLib\Exception\AMQPTimeoutException $e) {
            // Do nothing.
        } catch (\PhpAmqpLib\Exception\AMQPRuntimeException $e) {
            // Do nothing.
        }
    }

The timeout exception is expected, without the timeout the signalhandler never gets called, I guess because the stream stuff lower down is non tickable.

The AMQPRuntimeException is thrown by AMQPReader::wait because the call to select returns false, I just catch both exceptions & do nothing with them

I wonder if there's a better way to handle this? Before throwing either of the exceptions, check the result of socket_last_error and if the result isn't 0 or 10, throw the error? That way you can add @ to mask the warning & still get errors when required.

10 is the error code returned by socket_last_error when it is interrupted.

If this sounds like a good idea, I can send you a pull request with the changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions