From 1e0562923ab504c9a0da12d905dd9db684655018 Mon Sep 17 00:00:00 2001 From: chaz6chez Date: Wed, 9 Oct 2024 01:36:01 +0800 Subject: [PATCH] fix: RippleCoroutine.php --- src/Utils/Coroutine/Handlers/RippleCoroutine.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Utils/Coroutine/Handlers/RippleCoroutine.php b/src/Utils/Coroutine/Handlers/RippleCoroutine.php index 3df9904..38aae4a 100644 --- a/src/Utils/Coroutine/Handlers/RippleCoroutine.php +++ b/src/Utils/Coroutine/Handlers/RippleCoroutine.php @@ -28,9 +28,12 @@ class RippleCoroutine implements CoroutineInterface public function __construct(\Closure $func) { $this->_promise = $this->_async(function () use (&$promise, $func) { - call_user_func($func); - // 移除协程id及promise - $this->_promise = null; + try { + call_user_func($func); + } finally { + // 移除协程id及promise + $this->_promise = null; + } }); $this->_id = spl_object_hash($this->_promise); }