ext-openswoole
ext-openswoole copied to clipboard
Server::reply_task_result(): Server::finish() can only be used in the worker process
I trying to run a server->tick() in task worker. I enabled task_enable_coroutine
and task_use_object
as false.
$server->on("Task", function (Server $server, Task $task) {
$action = $task->data;
$server->tick(1000, function ($id) use ($server, $task, $action) {
......
if (count($list) < 1) {
// stop timer, remove key
$redis->del($this->key_system_action . $action["action_name"]);
$server->clearTimer($id);
$task->finish("No more device listen on :" . $this->key_system_action . $action["action_name"] . ", so stop the task.");
}
.......
});
});
I had follow the openswoole doc to use $task->finish() from Swoole\Server\Task to call finish() function instead of calling from Swoole\Server, but the log keep show this below whenever it call finish():
WARNING Server::reply_task_result(): Server::finish() can only be used in the worker process
- My
php --ri openswoole
openswoole
Open Swoole => enabled
Author => Open Swoole Group <[email protected]>
Version => 4.11.1
Built => Apr 28 2022 15:55:14
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1f 31 Mar 2020
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
postgresql => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
- What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ?
uname: Linux amassfintech.com 5.15.0-1017-aws #21~20.04.1-Ubuntu SMP Fri Aug 5 11:44:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
php: PHP 8.0.22
gcc: Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)