Skip to content

Commit

Permalink
use celery first if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hisham waleed karam committed Feb 6, 2019
1 parent a18bbd4 commit a84096b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions geonode/geoserver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from celery.app import shared_task
from celery.utils.log import get_task_logger

from .utils import check_broker_status
from .helpers import gs_slurp

logger = get_task_logger(__name__)
Expand All @@ -43,12 +43,17 @@ def thumbnail_task(self, instance, overwrite=False, check_bbox=False):


def async_thumbnail(instance, overwrite=False, check_bbox=False):
t = threading.Thread(
target=thumbnail_task.delay,
args=(instance, ),
kwargs={
'overwrite': overwrite,
'check_bbox': check_bbox
})
t.setDaemon(True)
t.start()
celery_enabled = check_broker_status()
if celery_enabled:
thumbnail_task.delay(
instance, overwrite=overwrite, check_bbox=check_bbox)
else:
t = threading.Thread(
target=thumbnail_task.delay,
args=(instance, ),
kwargs={
'overwrite': overwrite,
'check_bbox': check_bbox
})
t.setDaemon(True)
t.start()

0 comments on commit a84096b

Please sign in to comment.