예제 #1
0
파일: base.py 프로젝트: bmihelac/celery
    def __init__(self, main=None, loader=None, backend=None,
            amqp=None, events=None, log=None, control=None,
            set_as_current=True, accept_magic_kwargs=False,
            tasks=None, broker=None, **kwargs):
        self.clock = LamportClock()
        self.main = main
        self.amqp_cls = amqp or self.amqp_cls
        self.backend_cls = backend or self.backend_cls
        self.events_cls = events or self.events_cls
        self.loader_cls = loader or self.loader_cls
        self.log_cls = log or self.log_cls
        self.control_cls = control or self.control_cls
        self.set_as_current = set_as_current
        self.registry_cls = self.registry_cls if tasks is None else tasks
        self.accept_magic_kwargs = accept_magic_kwargs

        self.finalized = False
        self._pending = deque()
        self._tasks = instantiate(self.registry_cls)

        # these options are moved to the config to
        # simplify pickling of the app object.
        self._preconf = {}
        if broker:
            self._preconf["BROKER_URL"] = broker

        if self.set_as_current:
            self.set_current()
        self.on_init()
예제 #2
0
파일: base.py 프로젝트: eliziario/celery
    def start(self, argv=None):
        """Run :program:`celery` using `argv`.

        Uses :data:`sys.argv` if `argv` is not specified.

        """
        return instantiate("celery.bin.celery:CeleryCommand", app=self).execute_from_commandline(argv)
예제 #3
0
파일: snapshot.py 프로젝트: axiak/celery
def evcam(camera, freq=1.0, maxrate=None, loglevel=0,
        logfile=None, pidfile=None, timer=None, app=None):
    app = app_or_default(app)

    if pidfile:
        pidlock = platforms.create_pidlock(pidfile).acquire()
        atexit.register(pidlock.release)

    if not isinstance(loglevel, int):
        loglevel = LOG_LEVELS[loglevel.upper()]
    logger = app.log.setup_logger(loglevel=loglevel,
                                  logfile=logfile,
                                  name="celery.evcam")

    logger.info(
        "-> evcam: Taking snapshots with %s (every %s secs.)\n" % (
            camera, freq))
    state = app.events.State()
    cam = instantiate(camera, state, app=app,
                      freq=freq, maxrate=maxrate, logger=logger,
                      timer=timer)
    cam.install()
    conn = app.broker_connection()
    recv = app.events.Receiver(conn, handlers={"*": state.event})
    try:
        try:
            recv.capture(limit=None)
        except KeyboardInterrupt:
            raise SystemExit
    finally:
        cam.cancel()
        conn.close()
예제 #4
0
파일: base.py 프로젝트: eliziario/celery
    def worker_main(self, argv=None):
        """Run :program:`celery worker` using `argv`.

        Uses :data:`sys.argv` if `argv` is not specified.

        """
        return instantiate("celery.bin.worker:worker", app=self).execute_from_commandline(argv)
예제 #5
0
def evcam(camera, freq=1.0, maxrate=None, loglevel=0,
          logfile=None, pidfile=None, timer=None, app=None):
    """Start snapshot recorder."""
    app = app_or_default(app)

    if pidfile:
        platforms.create_pidlock(pidfile)

    app.log.setup_logging_subsystem(loglevel, logfile)

    print('-> evcam: Taking snapshots with {0} (every {1} secs.)'.format(
        camera, freq))
    state = app.events.State()
    cam = instantiate(camera, state, app=app, freq=freq,
                      maxrate=maxrate, timer=timer)
    cam.install()
    conn = app.connection_for_read()
    recv = app.events.Receiver(conn, handlers={'*': state.event})
    try:
        try:
            recv.capture(limit=None)
        except KeyboardInterrupt:
            raise SystemExit
    finally:
        cam.cancel()
        conn.close()
예제 #6
0
def evcam(camera, freq=1.0, maxrate=None, loglevel=0,
        logfile=None, pidfile=None, timer=None, app=None):
    app = app_or_default(app)

    if pidfile:
        platforms.create_pidlock(pidfile)

    app.log.setup_logging_subsystem(loglevel, logfile)

    logger.info(
        "-> evcam: Taking snapshots with %s (every %s secs.)\n" % (
            camera, freq))
    state = app.events.State()
    cam = instantiate(camera, state, app=app, freq=freq,
                      maxrate=maxrate, timer=timer)
    cam.install()
    conn = app.broker_connection()
    recv = app.events.Receiver(conn, handlers={"*": state.event})
    try:
        try:
            recv.capture(limit=None)
        except KeyboardInterrupt:
            raise SystemExit
    finally:
        cam.cancel()
        conn.close()
예제 #7
0
def beat():
    """ Start running celerybeat """
    import sys
    from celery.utils.imports import instantiate
    if len(sys.argv) < 2:
        print "usage: %s config.yaml [celery opts]" % sys.argv[0]
        sys.exit(1)

    init_celery(sys.argv.pop(1))

    try:
        instantiate(
            'celery.bin.celerybeat:BeatCommand',
            app=celery).execute_from_commandline(sys.argv)
    except ImportError:
        instantiate(
            'celery.bin.beat:beat',
            app=celery).execute_from_commandline(sys.argv)
예제 #8
0
 def add_actor(self, actor_name, actor_id):
     """Add actor to the actor registry and start the actor main method"""
     try:
         actor = instantiate(actor_name, connection = self.connection, 
                             id = actor_id)
         consumer = actor.Consumer(self.connection.channel())
         consumer.consume()
         self.actor_registry[actor.id] = consumer
         info('Register actor in the actor registry: %s' % actor_name)
         return actor.id
     except Exception as exc:
         error('Start actor error: %r', exc, exc_info=True)
예제 #9
0
 def add_actor(self, name, id = None):
     """Add actor to the actor registry and start the actor's main method"""
     try:
         actor = instantiate(name, connection = self.connection, 
                             id = id)
         self._start_actor_consumer(actor)
         if actor.id in self.actor_registry:
             warn('Actor with the same id already exists')
         debug('Register actor in the actor registry: %s' % name)
         return actor.id
     except Exception as exc:
         error('Start actor error: %r', exc, exc_info=True)
예제 #10
0
파일: task.py 프로젝트: chillbear/celery
 def start_strategy(self, app, consumer, **kwargs):
     return instantiate(self.Strategy, self, app, consumer, **kwargs)
예제 #11
0
 def worker_main(self, argv=None):
     return instantiate(
         'celery.bin.worker:worker',
         app=self).execute_from_commandline(argv)
예제 #12
0
파일: base.py 프로젝트: 277800076/celery
 def amqp(self):
     """AMQP related functionality: :class:`~@amqp`."""
     return instantiate(self.amqp_cls, app=self)
예제 #13
0
파일: base.py 프로젝트: 277800076/celery
 def events(self):
     """Consuming and sending events: :class:`~@events`."""
     return instantiate(self.events_cls, app=self)
예제 #14
0
 def instantiate(self, qualname, *args, **kwargs):
     return instantiate(qualname, *args, **kwargs)
예제 #15
0
 def __new__(cls, *args, **kwargs):
     return instantiate(options.auth_provider, *args, **kwargs)
예제 #16
0
파일: base.py 프로젝트: westurner/celery
 def worker_main(self, argv=None):
     return instantiate("celery.bin.celeryd:WorkerCommand", app=self) \
                 .execute_from_commandline(argv)
예제 #17
0
 def amqp(self):
     """AMQP related functionality: :class:`~@amqp`."""
     return instantiate(self.amqp_cls, app=self)
예제 #18
0
 def start_strategy(self, app, consumer, **kwargs):
     return instantiate(self.Strategy, self, app, consumer, **kwargs)
예제 #19
0
파일: base.py 프로젝트: westurner/celery
 def start(self, argv=None):
     return instantiate("celery.bin.celery:CeleryCommand", app=self) \
                 .execute_from_commandline(argv)
예제 #20
0
 def log(self):
     """Logging: :class:`~@log`."""
     return instantiate(self.log_cls, app=self)
예제 #21
0
 def events(self):
     """Consuming and sending events: :class:`~@events`."""
     return instantiate(self.events_cls, app=self)
예제 #22
0
 def control(self):
     """Remote control: :class:`~@control`."""
     return instantiate(self.control_cls, app=self)
예제 #23
0
 def control(self):
     return instantiate(self.control_cls, app=self)
예제 #24
0
파일: base.py 프로젝트: westurner/celery
 def amqp(self):
     """Sending/receiving messages.  See :class:`~celery.app.amqp.AMQP`."""
     return instantiate(self.amqp_cls, app=self)
예제 #25
0
 def log(self):
     return instantiate(self.log_cls, app=self)
예제 #26
0
 def events(self):
     return instantiate(self.events_cls, app=self)
예제 #27
0
 def worker_main(self, argv=None):
     return instantiate('celery.bin.worker:worker',
                        app=self).execute_from_commandline(argv)
예제 #28
0
def start_group(actor_type, count):
    actor_group = []
    [actor_group.append(instantiate(actor_type)) for _ in range(0, count)]
    wf = Workflow(actor_group)
    remote_group = list(wf.start())
    return remote_group    
예제 #29
0
파일: abstract.py 프로젝트: axiak/celery
 def instantiate(self, qualname, *args, **kwargs):
     return instantiate(qualname, *args, **kwargs)
예제 #30
0
파일: base.py 프로젝트: bmihelac/celery
 def amqp(self):
     """Sending/receiving messages.  See :class:`~celery.app.amqp.AMQP`."""
     return instantiate(self.amqp_cls, app=self)
예제 #31
0
파일: base.py 프로젝트: hongsw/celery
 def worker_main(self, argv=None):
     return instantiate('celery.bin.celeryd:WorkerCommand', app=self) \
                 .execute_from_commandline(argv)
예제 #32
0
파일: base.py 프로젝트: bmihelac/celery
 def control(self):
     """Controlling worker nodes.  See
     :class:`~celery.app.control.Control`."""
     return instantiate(self.control_cls, app=self)
예제 #33
0
파일: base.py 프로젝트: 277800076/celery
 def control(self):
     """Remote control: :class:`~@control`."""
     return instantiate(self.control_cls, app=self)
예제 #34
0
파일: workflow.py 프로젝트: xyicheng/cell
def start_group(actor_type, count):
    actor_group = []
    [actor_group.append(instantiate(actor_type)) for _ in range(0, count)]
    wf = Workflow(actor_group)
    remote_group = list(wf.start())
    return remote_group
예제 #35
0
파일: base.py 프로젝트: 277800076/celery
 def log(self):
     """Logging: :class:`~@log`."""
     return instantiate(self.log_cls, app=self)
예제 #36
0
파일: base.py 프로젝트: bmihelac/celery
 def log(self):
     """Logging utilities.  See :class:`~celery.app.log.Logging`."""
     return instantiate(self.log_cls, app=self)
예제 #37
0
 def start(self, argv=None):
     return instantiate(
         'celery.bin.celery:CeleryCommand',
         app=self).execute_from_commandline(argv)
예제 #38
0
 def control(self):
     return instantiate(self.control_cls, app=self)
예제 #39
0
 def amqp(self):
     return instantiate(self.amqp_cls, app=self)
예제 #40
0
 def amqp(self):
     return instantiate(self.amqp_cls, app=self)
예제 #41
0
 def events(self):
     return instantiate(self.events_cls, app=self)
예제 #42
0
파일: auth.py 프로젝트: boydjj/flower
 def __new__(cls, *args, **kwargs):
     return instantiate(options.auth_provider, *args, **kwargs)
예제 #43
0
파일: base.py 프로젝트: bmihelac/celery
 def events(self):
     """Sending/receiving events.  See :class:`~celery.events.Events`. """
     return instantiate(self.events_cls, app=self)
예제 #44
0
 def log(self):
     return instantiate(self.log_cls, app=self)