From 7d54267449a29aa7e2b25e9c873356264b543fe1 Mon Sep 17 00:00:00 2001 From: walkor Date: Mon, 13 Jun 2022 16:27:12 +0800 Subject: [PATCH] Update Timer.php --- Timer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Timer.php b/Timer.php index 348bb3a43..61fd8fd98 100644 --- a/Timer.php +++ b/Timer.php @@ -117,6 +117,12 @@ public static function add($time_interval, $func, $args = array(), $persistent = return self::$_event->add($time_interval, $persistent ? EventInterface::EV_TIMER : EventInterface::EV_TIMER_ONCE, $func, $args); } + + // If not workerman runtime just return. + if (!Worker::getAllWorkers()) { + throw new \Exception(); + return; + } if (!\is_callable($func)) { Worker::safeEcho(new Exception("not callable"));