Exemple #1
0
 def test_stop_pidbox_node(self):
     l = MyKombuConsumer(self.ready_queue,
                         self.eta_schedule,
                         send_events=False)
     l._pidbox_node_stopped = Event()
     l._pidbox_node_shutdown = Event()
     l._pidbox_node_stopped.set()
     l.stop_pidbox_node()
Exemple #2
0
    def __init__(self,
                 loglevel=None,
                 hostname=None,
                 ready_callback=noop,
                 queues=None,
                 app=None,
                 pidfile=None,
                 **kwargs):
        self.app = app_or_default(app or self.app)

        self._shutdown_complete = Event()
        self.setup_defaults(kwargs, namespace='celeryd')
        self.app.select_queues(queues)  # select queues subset.

        # Options
        self.loglevel = loglevel or self.loglevel
        self.hostname = hostname or socket.gethostname()
        self.ready_callback = ready_callback
        self._finalize = Finalize(self, self.stop, exitpriority=1)
        self.pidfile = pidfile
        self.pidlock = None
        self.use_eventloop = self.should_use_eventloop()

        # Update celery_include to have all known task modules, so that we
        # ensure all task modules are imported in case an execv happens.
        task_modules = set(task.__class__.__module__
                           for task in self.app.tasks.itervalues())
        self.app.conf.CELERY_INCLUDE = tuple(
            set(self.app.conf.CELERY_INCLUDE) | task_modules, )

        # Initialize boot steps
        self.pool_cls = _concurrency.get_implementation(self.pool_cls)
        self.components = []
        self.namespace = Namespace(app=self.app).apply(self, **kwargs)
Exemple #3
0
 def __init__(self, files,
              on_change=None, shutdown_event=None, interval=0.5):
     self.files = files
     self.interval = interval
     self._on_change = on_change
     self.modify_times = defaultdict(int)
     self.shutdown_event = shutdown_event or Event()
Exemple #4
0
    def __init__(self,
                 loglevel=None,
                 hostname=None,
                 ready_callback=noop,
                 queues=None,
                 app=None,
                 pidfile=None,
                 **kwargs):
        self.app = app_or_default(app or self.app)
        # all new threads start without a current app, so if an app is not
        # passed on to the thread it will fall back to the "default app",
        # which then could be the wrong app.  So for the worker
        # we set this to always return our app.  This is a hack,
        # and means that only a single app can be used for workers
        # running in the same process.
        set_default_app(self.app)
        self.app.finalize()
        trace._tasks = self.app._tasks

        self._shutdown_complete = Event()
        self.setup_defaults(kwargs, namespace='celeryd')
        self.app.select_queues(queues)  # select queues subset.

        # Options
        self.loglevel = loglevel or self.loglevel
        self.hostname = hostname or socket.gethostname()
        self.ready_callback = ready_callback
        self._finalize = Finalize(self, self.stop, exitpriority=1)
        self.pidfile = pidfile
        self.pidlock = None
        self.use_eventloop = (detect_environment() == 'default'
                              and self.app.broker_connection().is_evented
                              and not self.app.IS_WINDOWS)

        # Update celery_include to have all known task modules, so that we
        # ensure all task modules are imported in case an execv happens.
        task_modules = set(task.__class__.__module__
                           for task in self.app.tasks.itervalues())
        self.app.conf.CELERY_INCLUDE = tuple(
            set(self.app.conf.CELERY_INCLUDE) | task_modules, )

        # Initialize boot steps
        self.pool_cls = _concurrency.get_implementation(self.pool_cls)
        self.components = []
        self.namespace = Namespace(app=self.app).apply(self, **kwargs)
Exemple #5
0
    def __init__(self,
                 loglevel=None,
                 hostname=None,
                 ready_callback=noop,
                 queues=None,
                 app=None,
                 pidfile=None,
                 **kwargs):
        self.app = app_or_default(app or self.app)
        # all new threads start without a current app, so if an app is not
        # passed on to the thread it will fall back to the "default app",
        # which then could be the wrong app.  So for the worker
        # we set this to always return our app.  This is a hack,
        # and means that only a single app can be used for workers
        # running in the same process.
        set_default_app(self.app)
        self.app.finalize()
        trace._tasks = self.app._tasks

        self._shutdown_complete = Event()
        self.setup_defaults(kwargs, namespace="celeryd")
        self.app.select_queues(queues)  # select queues subset.

        # Options
        self.loglevel = loglevel or self.loglevel
        self.hostname = hostname or socket.gethostname()
        self.ready_callback = ready_callback
        self._finalize = Finalize(self, self.stop, exitpriority=1)
        self.pidfile = pidfile
        self.pidlock = None
        self.use_eventloop = (detect_environment() == "default"
                              and self.app.broker_connection().is_evented)

        # Initialize boot steps
        self.pool_cls = _concurrency.get_implementation(self.pool_cls)
        self.components = []
        self.namespace = Namespace(app=self.app).apply(self, **kwargs)
Exemple #6
0
 def test_stop_pidbox_node(self):
     l = MyKombuConsumer(self.ready_queue, timer=self.timer)
     l._pidbox_node_stopped = Event()
     l._pidbox_node_shutdown = Event()
     l._pidbox_node_stopped.set()
     l.stop_pidbox_node()