mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +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->hasCancelledRun()){
|
||||
$task->onCompletion($this->server);
|
||||
$this->server->getScheduler()->removeLocalComplex($task);
|
||||
try{
|
||||
$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);
|
||||
|
@ -174,10 +174,11 @@ class ServerScheduler{
|
||||
*/
|
||||
public function removeLocalComplex(AsyncTask $for) : bool{
|
||||
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]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user