项目作者: lecardozo

项目描述 :
Celery worker for R tasks! Celery :left_right_arrow: R
高级语言: R
项目地址: git://github.com/lecardozo/rworker.git
创建时间: 2017-07-22T18:58:19Z
项目社区:https://github.com/lecardozo/rworker

开源协议:Other

下载


rworker Travis-CI Build Status

Celery worker for R tasks.

Motivation

The main motivation for this package was the need for executing long running R functions
triggered by Celery (asynchronous task queue package for Python).

Data flow

Usage

Start consuming tasks from R
  1. library(rworker)
  2. library(magrittr)
  3. # Broker url
  4. redis_url <- 'redis://localhost:6379'
  5. # Instantiate Rworker object
  6. consumer <- rworker(name='celery', workers=2, queue=redis_url, backend=redis_url)
  7. # Register tasks
  8. (function(){
  9. Sys.sleep(5)
  10. }) %>% consumer$task(name='long_running_task')
  11. # Start consuming messages
  12. consumer$consume()

The rworker function returns a Rworker object. This object is responsible for registering tasks, listening for messages coming from the message queue and triggering tasks execution on background processes

Send tasks from Python
  1. from celery import Celery
  2. worker = Celery('app', broker="redis://localhost:6379/0", backend="redis://localhost:6379/0")
  3. worker.send_task('long_running_task')

Tutorial

You can find more information about usage here.