Skip to content
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

tick handling and shutdown behaviour #306

Open
bashilbers opened this issue May 18, 2017 · 1 comment
Open

tick handling and shutdown behaviour #306

bashilbers opened this issue May 18, 2017 · 1 comment

Comments

@bashilbers
Copy link
Contributor

bashilbers commented May 18, 2017

Hi guys/girls,

2 questions:

  1. Why don't you register a tick handler? I see the declare construct being used, what purpose does it have without having a registered tick handler?
  2. Shutdown behaviour. Currently the consumer's invoke method is blocking the shutdown mechanism. I.e. if consuming a particular message takes 3h to consume, and you send in a SIGINT or SIGTERM signal (also, the default supervisord stopping signal), you'll have to wait 3hours until the consumer notices that it should've stopped. Not ideal if you ask me.
@GDmac
Copy link

GDmac commented Nov 30, 2018

Declare tick should not be used at all, many places it is suggested to use pcntl_signal_dispatch instead.
Inside the drivers, instead of usleep(), could use time_nanosleep, which is interruptable.

pcntl_signal_dispatch();
$nano = time_nanosleep(0, 100000000);
if ($nano === true) {
  // slept
} elseif ($nano === false) {
  // nanosleep fail
  usleep(100000);
} elseif (is_array($nano)) {
  // Interrupted by a signal
  pcntl_signal_dispatch();
  return array(null, null);
}
pcntl_signal_dispatch();

(edit: via GeniusesOfSymfony/WebSocketBundle#125 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants