Skip to content

Commit

Permalink
Merge branch '3.0' of github.com:celery/celery into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jan 30, 2013
2 parents 1fc7c23 + d19dc58 commit 08576ac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions celery/app/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def ping(self):
def active_queues(self):
return self._request('active_queues')

def conf(self):
return self._request('dump_conf')

class Control(object):
Mailbox = Mailbox
Expand Down
31 changes: 31 additions & 0 deletions celery/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import sys
import traceback
import warnings
import types
import datetime

from functools import partial, wraps
from inspect import getargspec
Expand Down Expand Up @@ -199,6 +201,35 @@ def strtobool(term, table={'false': False, 'no': False, '0': False,
return term


def jsonify(obj):
"Transforms object making it suitable for json serialization"
if isinstance(obj, (int, float, basestring, types.NoneType)):
return obj
elif isinstance(obj, (tuple, list)):
return map(jsonify, obj)
elif isinstance(obj, dict):
return dict([(k,jsonify(v)) for k,v in obj.iteritems()])
# See "Date Time String Format" in the ECMA-262 specification.
elif isinstance(obj, datetime.datetime):
r = obj.isoformat()
if obj.microsecond:
r = r[:23] + r[26:]
if r.endswith('+00:00'):
r = r[:-6] + 'Z'
return r
elif isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, datetime.time):
r = obj.isoformat()
if obj.microsecond:
r = r[:12]
return r
elif isinstance(obj, datetime.timedelta):
return str(obj)
else:
raise ValueError("Unsupported type: %s" % type(obj))


def gen_task_name(app, name, module_name):
try:
module = sys.modules[module_name]
Expand Down
12 changes: 11 additions & 1 deletion celery/worker/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
"""
from __future__ import absolute_import

import os

from datetime import datetime
from future_builtins import map

from kombu.utils.encoding import safe_repr

from celery.platforms import signals as _signals
from celery.utils import timeutils
from celery.utils.compat import UserDict
from celery.utils.log import get_logger
from celery.utils import jsonify

from . import state
from .state import revoked
Expand Down Expand Up @@ -192,7 +196,8 @@ def stats(panel, **kwargs):
return {'total': state.total_count,
'consumer': panel.consumer.info,
'pool': panel.consumer.pool.info,
'autoscaler': asinfo}
'autoscaler': asinfo,
'pid': os.getpid()}


@Panel.register
Expand Down Expand Up @@ -287,3 +292,8 @@ def active_queues(panel):
"""Returns the queues associated with each worker."""
return [dict(queue.as_dict(recurse=True))
for queue in panel.consumer.task_consumer.queues]


@Panel.register
def dump_conf(panel, **kwargs):
return jsonify(dict(panel.app.conf))

0 comments on commit 08576ac

Please sign in to comment.