@@ -212,10 +212,12 @@ final class Swoole implements EventInterface
*/
public function stop(): void
{
- // cancel all coroutines before Event::exit
+ // Cancel all coroutines before Event::exit
foreach (Coroutine::listCoroutines() as $coroutine) {
Coroutine::cancel($coroutine);
}
+ // Wait for coroutines to exit
+ usleep(20000);
Event::exit();
@@ -241,7 +241,6 @@ class Http
// Read file content from disk piece by piece and send to client.
$doWrite = function () use ($connection, $handler, $length, $offsetEnd) {
// Send buffer not full.
- // @phpstan-ignore-next-line
while ($connection->context->bufferFull === false) {
// Read from disk.
$size = 1024 * 1024;