From eff0fa1c8b9ec236234053bfc0bf3f6e2152d4c0 Mon Sep 17 00:00:00 2001 From: chaz6chez Date: Wed, 2 Oct 2024 02:01:30 +0800 Subject: [PATCH] fix: all coroutines must be canceled before Event::exit --- src/Events/Swoole.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Events/Swoole.php b/src/Events/Swoole.php index e703d14b5..e61c9b7f4 100644 --- a/src/Events/Swoole.php +++ b/src/Events/Swoole.php @@ -15,6 +15,7 @@ namespace Workerman\Events; +use Swoole\Coroutine; use Swoole\Event; use Swoole\Process; use Swoole\Timer; @@ -211,6 +212,10 @@ public function run(): void */ public function stop(): void { + // cancel all coroutines before Event::exit + foreach (Coroutine::listCoroutines() as $coroutine) { + Coroutine::cancel($coroutine); + } Event::exit(); posix_kill(posix_getpid(), SIGINT); }