From 52bd05e0010c37fe1e98bda1031a713e6312e107 Mon Sep 17 00:00:00 2001 From: Ethan Date: Sun, 27 Oct 2019 18:22:52 -0400 Subject: [PATCH 1/2] Fix HTTPS websocket support --- .../static/celery_progress/celery_progress_websockets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/celery_progress/static/celery_progress/celery_progress_websockets.js b/celery_progress/static/celery_progress/celery_progress_websockets.js index 4ab8e1c..5d2ea2b 100644 --- a/celery_progress/static/celery_progress/celery_progress_websockets.js +++ b/celery_progress/static/celery_progress/celery_progress_websockets.js @@ -28,7 +28,8 @@ var CeleryWebSocketProgressBar = (function () { var resultElement = options.resultElement || document.getElementById(resultElementId); var onResult = options.onResult || onResultDefault; - var ProgressSocket = new WebSocket('ws://' + window.location.host + progressUrl); + var ProgressSocket = new WebSocket(location.protocol === 'https:' ? 'wss' : 'ws' + '://' + + window.location.host + progressUrl); ProgressSocket.onopen = function (event) { ProgressSocket.send(JSON.stringify({'type': 'check_task_completion'})); From 2e5a35b5496fdb1827e3cd3f9524666d49eb61e6 Mon Sep 17 00:00:00 2001 From: Ethan Date: Sun, 27 Oct 2019 22:05:16 -0400 Subject: [PATCH 2/2] Fix RuntimeError on task finish --- celery_progress/backend.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/celery_progress/backend.py b/celery_progress/backend.py index 90e736d..834b610 100644 --- a/celery_progress/backend.py +++ b/celery_progress/backend.py @@ -2,7 +2,7 @@ from abc import ABCMeta, abstractmethod from decimal import Decimal -from celery.result import AsyncResult +from celery.result import AsyncResult, allow_join_result try: from asgiref.sync import async_to_sync @@ -104,12 +104,13 @@ def __init__(self, task_id): def get_info(self): if self.result.ready(): success = self.result.successful() - return { - 'complete': True, - 'success': success, - 'progress': _get_completed_progress(), - 'result': self.result.get(self.task_id) if success else None, - } + with allow_join_result(): + return { + 'complete': True, + 'success': success, + 'progress': _get_completed_progress(), + 'result': self.result.get(self.task_id) if success else None, + } elif self.result.state == PROGRESS_STATE: return { 'complete': False,