Coroutine::getSuspendLocation
(PHP 8.6+, True Async 1.0)
public Coroutine::getSuspendLocation(): string
Gibt den Unterbrechungsort der Coroutine im Format "Datei:Zeile" zurueck. Wenn die Information nicht verfuegbar ist, wird "unknown" zurueckgegeben.
Rueckgabewert
string – eine Zeichenkette wie "/app/script.php:42" oder "unknown".
Beispiele
Beispiel #1 Blockierte Coroutine diagnostizieren
<?php
use function Async\spawn;
use function Async\suspend;
use function Async\get_coroutines;
spawn(function() {
file_get_contents('https://slow-api.example.com'); // hier blockiert
});
suspend();
foreach (get_coroutines() as $coro) {
if ($coro->isSuspended()) {
echo "Coroutine #{$coro->getId()} wartet bei: {$coro->getSuspendLocation()}\n";
}
}
Siehe auch
- Coroutine::getSuspendFileAndLine – Datei und Zeile als Array
- Coroutine::getSpawnLocation – Erstellungsort
- Coroutine::getTrace – Vollstaendiger Aufrufstapel