Here are the examples of the python api scrapi.events.creates_task taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
Project: scrapi Source File: tasks.py
@app.task
@events.creates_task(events.HARVESTER_RUN)
def run_harvester(harvester_name, start_date=None, end_date=None):
logger.info('Running harvester "{}"'.format(harvester_name))
start_date = start_date or date.today() - timedelta(settings.DAYS_BACK)
end_date = end_date or date.today()
normalization = begin_normalization.s(harvester_name)
start_harvest = harvest.si(harvester_name, timestamp(), start_date=start_date, end_date=end_date)
# Form and start a celery chain
(start_harvest | normalization).apply_async()
3
Example 2
Project: scrapi Source File: tasks.py
@events.creates_task(events.PROCESSING)
@events.creates_task(events.NORMALIZATION)
def spawn_tasks(raw, timestamps, harvester_name):
raw['timestamps'] = timestamps
raw['timestamps']['normalizeTaskCreated'] = timestamp()
chain = (normalize.si(raw, harvester_name) | process_normalized.s(raw))
chain.apply_async()
process_raw.delay(raw)