Le chromium n'existe que dans Celery
This commit is contained in:
parent
15a562f390
commit
be8b6b8f48
@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery, Task
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
from celery.utils.log import get_task_logger
|
from celery.utils.log import get_task_logger
|
||||||
|
|
||||||
@ -20,8 +20,6 @@ app = Celery("agenda_culturel")
|
|||||||
|
|
||||||
logger = get_task_logger(__name__)
|
logger = get_task_logger(__name__)
|
||||||
|
|
||||||
chromiumDownloader = ChromiumHeadlessDownloader()
|
|
||||||
|
|
||||||
|
|
||||||
# Using a string here means the worker doesn't have to serialize
|
# Using a string here means the worker doesn't have to serialize
|
||||||
# the configuration object to child processes.
|
# the configuration object to child processes.
|
||||||
@ -76,7 +74,17 @@ def import_events_from_json(self, json):
|
|||||||
close_import_task(self.request.id, False, e, importer)"""
|
close_import_task(self.request.id, False, e, importer)"""
|
||||||
|
|
||||||
|
|
||||||
@app.task(bind=True)
|
class ChromiumTask(Task):
|
||||||
|
_chm = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def chromiumDownloader(self):
|
||||||
|
if self._chm is None:
|
||||||
|
self._chm = ChromiumHeadlessDownloader()
|
||||||
|
return self._chm
|
||||||
|
|
||||||
|
|
||||||
|
@app.task(base=ChromiumTask, bind=True)
|
||||||
def run_recurrent_import(self, pk):
|
def run_recurrent_import(self, pk):
|
||||||
from agenda_culturel.models import RecurrentImport, BatchImportation
|
from agenda_culturel.models import RecurrentImport, BatchImportation
|
||||||
from .db_importer import DBImporterEvents
|
from .db_importer import DBImporterEvents
|
||||||
@ -98,7 +106,7 @@ def run_recurrent_import(self, pk):
|
|||||||
downloader = (
|
downloader = (
|
||||||
SimpleDownloader()
|
SimpleDownloader()
|
||||||
if rimport.downloader == RecurrentImport.DOWNLOADER.SIMPLE
|
if rimport.downloader == RecurrentImport.DOWNLOADER.SIMPLE
|
||||||
else chromiumDownloader
|
else self.chromiumDownloader
|
||||||
)
|
)
|
||||||
if rimport.processor == RecurrentImport.PROCESSOR.ICAL:
|
if rimport.processor == RecurrentImport.PROCESSOR.ICAL:
|
||||||
extractor = ICALExtractor()
|
extractor = ICALExtractor()
|
||||||
|
Loading…
Reference in New Issue
Block a user