Skip to content

Commit 1e45852

Browse files
author
Ask Solem
committed
93% total coverage.
celery.bin.celeryd and celery.concurrency.processes now fully covered.
1 parent a085889 commit 1e45852

File tree

7 files changed

+414
-22
lines changed

7 files changed

+414
-22
lines changed

celery/bin/celeryd.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def dump_version(*args):
160160

161161

162162
class Worker(object):
163+
WorkController = WorkController
163164

164165
def __init__(self, concurrency=conf.CELERYD_CONCURRENCY,
165166
loglevel=conf.CELERYD_LOG_LEVEL, logfile=conf.CELERYD_LOG_FILE,
@@ -195,15 +196,6 @@ def run(self):
195196
print("celery@%s v%s is starting." % (self.hostname,
196197
celery.__version__))
197198

198-
199-
if conf.RESULT_BACKEND == "database" \
200-
and self.settings.DATABASE_ENGINE == "sqlite3" and \
201-
self.concurrency > 1:
202-
warnings.warn("The sqlite3 database engine doesn't handle "
203-
"concurrency well. Will use a single process only.",
204-
UserWarning)
205-
self.concurrency = 1
206-
207199
if getattr(self.settings, "DEBUG", False):
208200
warnings.warn("Using settings.DEBUG leads to a memory leak, "
209201
"never use this setting in a production environment!")
@@ -232,7 +224,6 @@ def init_queues(self):
232224
if queue not in conf.QUEUES:
233225
if conf.CREATE_MISSING_QUEUES:
234226
Router(queues=conf.QUEUES).add_queue(queue)
235-
print("QUEUES: %s" % conf.QUEUES)
236227
else:
237228
raise ImproperlyConfigured(
238229
"Queue '%s' not defined in CELERY_QUEUES" % queue)
@@ -293,7 +284,7 @@ def startup_info(self):
293284
}
294285

295286
def run_worker(self):
296-
worker = WorkController(concurrency=self.concurrency,
287+
worker = self.WorkController(concurrency=self.concurrency,
297288
loglevel=self.loglevel,
298289
logfile=self.logfile,
299290
hostname=self.hostname,
@@ -381,7 +372,7 @@ def set_process_status(info):
381372
arg_start = "manage" in sys.argv[0] and 2 or 1
382373
if sys.argv[arg_start:]:
383374
info = "%s (%s)" % (info, " ".join(sys.argv[arg_start:]))
384-
platform.set_mp_process_title("celeryd", info=info)
375+
return platform.set_mp_process_title("celeryd", info=info)
385376

386377

387378
def run_worker(**options):

celery/concurrency/processes/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TaskPool(object):
2727
The logger used for debugging.
2828
2929
"""
30+
Pool = Pool
3031

3132
def __init__(self, limit, logger=None, initializer=None,
3233
maxtasksperchild=None, timeout=None, soft_timeout=None,
@@ -46,11 +47,11 @@ def start(self):
4647
Will pre-fork all workers so they're ready to accept tasks.
4748
4849
"""
49-
self._pool = Pool(processes=self.limit,
50-
initializer=self.initializer,
51-
timeout=self.timeout,
52-
soft_timeout=self.soft_timeout,
53-
maxtasksperchild=self.maxtasksperchild)
50+
self._pool = self.Pool(processes=self.limit,
51+
initializer=self.initializer,
52+
timeout=self.timeout,
53+
soft_timeout=self.soft_timeout,
54+
maxtasksperchild=self.maxtasksperchild)
5455

5556
def stop(self):
5657
"""Gracefully stop the pool."""
@@ -96,7 +97,7 @@ def on_ready(self, callbacks, errbacks, ret_value):
9697

9798
if isinstance(ret_value, ExceptionInfo):
9899
if isinstance(ret_value.exception, (
99-
SystemExit, KeyboardInterrupt)): # pragma: no cover
100+
SystemExit, KeyboardInterrupt)):
100101
raise ret_value.exception
101102
[errback(ret_value) for errback in errbacks]
102103
else:

celery/platform.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ def set_process_title(progname, info=None):
5353
Only works if :mod`setproctitle` is installed.
5454
5555
"""
56+
proctitle = "[%s]" % progname
57+
proctitle = info and "%s %s" % (proctitle, info) or proctitle
5658
if _setproctitle:
57-
proctitle = "[%s]" % progname
58-
proctitle = info and "%s %s" % (proctitle, info) or proctitle
5959
_setproctitle(proctitle)
60+
return proctitle
6061

6162

6263
def set_mp_process_title(progname, info=None):

celery/tests/test_bin/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)