Skip to content

Commit

Permalink
fix: all coroutines must be canceled before Event::exit
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Oct 1, 2024
1 parent 965a4ca commit eff0fa1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Events/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Workerman\Events;

use Swoole\Coroutine;
use Swoole\Event;
use Swoole\Process;
use Swoole\Timer;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit eff0fa1

Please sign in to comment.