Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine::getBackTrace(int $cid = 0, int $options = \DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array|false
Coroutine ID. By default, use the ID of current coroutine.
DEBUG_BACKTRACE_PROVIDE_OBJECT
the depth of the backtrace.
an array of backtrace.
Get the backtrace of a coroutine by coroutine ID.
<?php
function test1() {
test2();
}
function test2() {
while(true) {
co::sleep(10);
echo __FUNCTION__." \n";
}
}
$cid = go(function () {
test1();
});
go(function () use ($cid) {
while(true) {
echo "BackTrace[$cid]:\n-----------------------------------------------\n";
var_dump(co::getBackTrace($cid))."\n";
co::sleep(3);
}
});