mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
Scheduler: Catch exceptions thrown from AsyncTask->onCompletion()
This commit is contained in:
parent
e024f381c9
commit
e0d5c79848
@ -159,8 +159,17 @@ class AsyncPool{
|
|||||||
}
|
}
|
||||||
if($task->isGarbage() and !$task->isRunning() and !$task->isCrashed()){
|
if($task->isGarbage() and !$task->isRunning() and !$task->isCrashed()){
|
||||||
if(!$task->hasCancelledRun()){
|
if(!$task->hasCancelledRun()){
|
||||||
$task->onCompletion($this->server);
|
try{
|
||||||
$this->server->getScheduler()->removeLocalComplex($task);
|
$task->onCompletion($this->server);
|
||||||
|
if(!$this->server->getScheduler()->removeLocalComplex($task)){
|
||||||
|
$this->server->getLogger()->notice("AsyncTask " . get_class($task) . " stored local complex data but did not remove them after completion");
|
||||||
|
}
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
$this->server->getLogger()->critical("Could not execute completion of asychronous task " . (new \ReflectionClass($task))->getShortName() . ": " . $e->getMessage());
|
||||||
|
$this->server->getLogger()->logException($e);
|
||||||
|
|
||||||
|
$this->server->getScheduler()->removeLocalComplex($task); //silent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->removeTask($task);
|
$this->removeTask($task);
|
||||||
|
@ -174,10 +174,11 @@ class ServerScheduler{
|
|||||||
*/
|
*/
|
||||||
public function removeLocalComplex(AsyncTask $for) : bool{
|
public function removeLocalComplex(AsyncTask $for) : bool{
|
||||||
if(isset($this->objectStore[$for])){
|
if(isset($this->objectStore[$for])){
|
||||||
Server::getInstance()->getLogger()->notice("AsyncTask " . get_class($for) . " stored local complex data but did not remove them after completion");
|
|
||||||
unset($this->objectStore[$for]);
|
unset($this->objectStore[$for]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user