Browse Source

Update Timer.php

walkor 3 năm trước cách đây
mục cha
commit
4109aefdc3
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      src/Timer.php

+ 6 - 0
src/Timer.php

@@ -114,6 +114,12 @@ class Timer
         if (self::$_event) {
             return $persistent ? self::$_event->repeat($time_interval, $func, $args) : self::$_event->delay($time_interval, $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"));