From e033360a4ebd7148378986833a6729ac8c0ae134 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Tue, 16 Jun 2015 16:21:31 -0400 Subject: [PATCH] Fix error when deleting SoundCloud tracks --- .../application/services/CeleryService.php | 9 ++++----- .../services/ThirdPartyCeleryService.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/services/CeleryService.php b/airtime_mvc/application/services/CeleryService.php index f47ccd715..9f21af3e4 100644 --- a/airtime_mvc/application/services/CeleryService.php +++ b/airtime_mvc/application/services/CeleryService.php @@ -81,6 +81,10 @@ class CeleryService { // If the message isn't ready yet (Celery hasn't finished the task), // only throw an exception if the message has timed out. if ($message == FALSE && self::_checkMessageTimeout($task)) { + // If the task times out, mark it as failed. We don't want to remove the + // track reference here in case it was a deletion that failed, for example. + $task->setDbStatus(CELERY_FAILED_STATUS); + $task->save(); throw new CeleryTimeoutException("Celery task " . $task->getDbName() . " with ID " . $task->getDbId() . " timed out"); } @@ -117,11 +121,6 @@ class CeleryService { $message = self::_getTaskMessage($task); self::_processTaskMessage($task, $message); } catch (CeleryTimeoutException $e) { - // If the task times out, mark it as failed. We don't want to remove the - // track reference here in case it was a deletion that failed, for example. - // TODO: Move this somewhere more appropriate - $task->setDbStatus(CELERY_FAILED_STATUS); - $task->save(); Logging::info($e->getMessage()); } catch (Exception $e) { // Because $message->result can be either an object or a string, sometimes diff --git a/airtime_mvc/application/services/ThirdPartyCeleryService.php b/airtime_mvc/application/services/ThirdPartyCeleryService.php index 5588c2cf7..ec3527545 100644 --- a/airtime_mvc/application/services/ThirdPartyCeleryService.php +++ b/airtime_mvc/application/services/ThirdPartyCeleryService.php @@ -114,6 +114,15 @@ abstract class ThirdPartyCeleryService extends ThirdPartyService { $ref->save(); } + /** + * Field accessor for $_CELERY_DELETE_TASK_NAME + * + * @return string the Celery task name for deleting tracks from this service + */ + public function getCeleryDeleteTaskName() { + return static::$_CELERY_DELETE_TASK_NAME; + } + /** * Build a parameter array for the file being uploaded to a third party service * @@ -123,13 +132,4 @@ abstract class ThirdPartyCeleryService extends ThirdPartyService { */ abstract protected function _getUploadData($file); - /** - * Field accessor for $_CELERY_DELETE_TASK_NAME - * - * @return string the Celery task name for deleting tracks from this service - */ - public function getCeleryDeleteTaskName() { - return self::$_CELERY_DELETE_TASK_NAME; - } - } \ No newline at end of file