Coroutine::getSuspendLocation
(PHP 8.6+, True Async 1.0)
public Coroutine::getSuspendLocation(): string
Retourne l’emplacement de suspension de la coroutine au format "fichier:ligne". Si l’information n’est pas disponible, retourne "unknown".
Valeur de retour
string – une chaîne comme "/app/script.php:42" ou "unknown".
Exemples
Exemple #1 Diagnostic d’une coroutine bloquée
<?php
use function Async\spawn;
use function Async\suspend;
use function Async\get_coroutines;
spawn(function() {
file_get_contents('https://slow-api.example.com'); // bloquée ici
});
suspend();
foreach (get_coroutines() as $coro) {
if ($coro->isSuspended()) {
echo "Coroutine #{$coro->getId()} waiting at: {$coro->getSuspendLocation()}\n";
}
}
Voir aussi
- Coroutine::getSuspendFileAndLine – Fichier et ligne sous forme de tableau
- Coroutine::getSpawnLocation – Emplacement de création
- Coroutine::getTrace – Pile d’appels complète