original_string: private function finalize(TaskExecutionInterface $execution, $start)
      {
          // this find is necessary because the storage could be
          // invalid (clear in doctrine) after handling an execution.
          $execution = $this->taskExecutionRepository->findByUuid($execution->getUuid());
  
          if ($execution->getStatus() !== TaskStatus::PLANNED) {
              $execution->setEndTime(new \DateTime());
              $execution->setDuration(microtime(true) - $start);
          }
  
          $this->eventDispatcher->dispatch(
              Events::TASK_FINISHED,
              new TaskExecutionEvent($execution->getTask(), $execution)
          );
  
          $this->taskExecutionRepository->save($execution);
      }
code: private function finalize(TaskExecutionInterface $execution, $start)
      {
          // this find is necessary because the storage could be
          // invalid (clear in doctrine) after handling an execution.
          $execution = $this->taskExecutionRepository->findByUuid($execution->getUuid());
  
          if ($execution->getStatus() !== TaskStatus::PLANNED) {
              $execution->setEndTime(new \DateTime());
              $execution->setDuration(microtime(true) - $start);
          }
  
          $this->eventDispatcher->dispatch(
              Events::TASK_FINISHED,
              new TaskExecutionEvent($execution->getTask(), $execution)
          );
  
          $this->taskExecutionRepository->save($execution);
      }
code_tokens: private function finalize ( TaskExecutionInterface $ execution , $ start ) { // this find is necessary because the storage could be // invalid (clear in doctrine) after handling an execution. $ execution = $ this -> taskExecutionRepository -> findByUuid ( $ execution -> getUuid ( ) ) ; if ( $ execution -> getStatus ( ) !== TaskStatus :: PLANNED ) { $ execution -> setEndTime ( new \ DateTime ( ) ) ; $ execution -> setDuration ( microtime ( true ) - $ start ) ; } $ this -> eventDispatcher -> dispatch ( Events :: TASK_FINISHED , new TaskExecutionEvent ( $ execution -> getTask ( ) , $ execution ) ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; }
docstring: Finalizes given execution.
  
  @param TaskExecutionInterface $execution
  @param int $start
docstring_tokens: Finalizes given execution .