Skip to content

Commit

Permalink
Merge pull request #1059 from chaz6chez/fix/swoole-event
Browse files Browse the repository at this point in the history
fix: all coroutines must be canceled before Event::exit
  • Loading branch information
walkor authored Oct 2, 2024
2 parents 965a4ca + eff0fa1 commit 8e1dfd8
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 8e1dfd8

Please sign in to comment.