Open
Description
Issue:
I ran a simple http server script using swoole 6 and SWOOLE_THREAD mode with coroutine option disabled. The $server->taskWaitMulti does not make onTask callback running. It work normally in SWOOLE_PROCESS and SWOOLE_THREAD with coroutine enabled.
1. What did you do? If possible, provide a simple script for reproducing the error.
I ran this script with Swoole 6
<?php
declare(strict_types=1);
use \Swoole\Http;
use \Swoole\Constant;
require_once __DIR__ . '/../vendor/autoload.php';
$server = new Http\Server('0.0.0.0', 4000, SWOOLE_THREAD);
$server->set([
Constant::OPTION_ENABLE_COROUTINE => true,
Constant::OPTION_WORKER_NUM => 1,
Constant::OPTION_TASK_WORKER_NUM => 2,
Constant::OPTION_DEBUG_MODE => true,
Constant::OPTION_TRACE_FLAGS => SWOOLE_TRACE_ALL
]);
$server->on(
Constant::EVENT_TASK,
function (Swoole\Server $server, int $task_id, int $src_worker_id, mixed $data) {
var_dump($data);
$server->finish(1);
}
);
$server->on(
Constant::EVENT_FINISH,
function(Swoole\Server $server, int $task_id, mixed $data) {
var_dump($data);
}
);
$server->on(
Constant::EVENT_REQUEST,
function (Http\Request $request, Http\Response $response) use ($server) {
var_dump($server->taskWaitMulti([1, 2]));
$response->header('Content-Type', 'application/json');
$response->end(
json_encode([
"message" => 'Hello World'
])
);
}
);
$server->on(Constant::EVENT_START, function (Http\Server $server) {
print($server->port);
});
$server->start();
2. What did you expect to see?
var_dump($data) of onTask callback show data to console.
3. What did you see instead?
It does not run any thing and cause request to hang.
4. What version of Swoole are you using (show your php --ri swoole)?
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 6.0.2
Built => May 9 2025 23:43:06
coroutine => enabled with boost asm context
debug => enabled
trace_log => enabled
kqueue => enabled
thread => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 3.4.1 11 Feb 2025
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
curl-version => 8.13.0
c-ares => 1.34.5
zlib => 1.2.12
brotli => E16781312/D16781312
coroutine_pgsql => enabled
coroutine_sqlite => enabled
Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
5. What is your machine environment used (show your uname -a
& php -v
& gcc -v
) ?
uname -a
Darwin Tams-MacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:03:40 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6041 arm64
php -v
PHP 8.4.6 (cli) (built: May 12 2025 01:04:27) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.4.6, Copyright (c) Zend Technologies
with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
gcc -v
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Metadata
Metadata
Assignees
Labels
No labels