Ask Solem 15 years ago
parent
commit
e68b712eb2

+ 1 - 0
celery/bin/celeryd.py

@@ -105,6 +105,7 @@ option_list = (
             help="Run in the background as a daemon."),
 )
 
+
 def parse_options(arguments):
     parser = optparse.OptionParser(option_list=option_list)
     options, values = parser.parse_args(arguments)

+ 4 - 4
celery/datastructures.py

@@ -48,9 +48,9 @@ class PositionQueue(UserList):
 
 class ExceptionInfo(object):
     """Exception wrapping an exception and its traceback.
-    
+
     :param exc_info: The exception tuple info as returned by
-        :func:`traceback.format_exception`. 
+        :func:`traceback.format_exception`.
 
 
     .. attribute:: exception
@@ -62,11 +62,11 @@ class ExceptionInfo(object):
         A traceback from the point when :attr:`exception` was raised.
 
     """
-    
+
     def __init__(self, exc_info):
         type_, exception, tb = exc_info
         self.exception = exception
         self.traceback = '\n'.join(traceback.format_exception(*exc_info))
-        
+
     def __str__(self):
         return str(self.exception)

+ 4 - 4
celery/fields.py

@@ -27,15 +27,15 @@ class PickledObjectField(models.Field):
             except:
                 # If an error was raised, just return the plain value
                 return value
-    
+
     def get_db_prep_save(self, value):
         if value is not None and not isinstance(value, PickledObject):
             value = PickledObject(pickle.dumps(value))
         return value
-    
-    def get_internal_type(self): 
+
+    def get_internal_type(self):
         return 'TextField'
-    
+
     def get_db_prep_lookup(self, lookup_type, value):
         if lookup_type == 'exact':
             value = self.get_db_prep_save(value)

+ 2 - 1
celery/management/commands/celeryd.py

@@ -3,6 +3,7 @@ from django.core.management.base import BaseCommand
 from celery.bin.celeryd import main, option_list
 from celery.conf import LOG_LEVELS
 
+
 class Command(BaseCommand):
     option_list = BaseCommand.option_list + option_list
     help = 'Run the celery daemon'
@@ -15,4 +16,4 @@ class Command(BaseCommand):
              logfile=options.get('logfile'),
              loglevel=options.get('loglevel'),
              pidfile=options.get('pidfile'),
-             queue_wakeup_after=options.get('queue_wakeup_after'))
+             queue_wakeup_after=options.get('queue_wakeup_after'))

+ 0 - 1
celery/managers.py

@@ -52,7 +52,6 @@ class TaskManager(models.Manager):
             task.save()
 
 
-
 class PeriodicTaskManager(models.Manager):
     """Manager for :class:`celery.models.PeriodicTask` models."""
 

+ 14 - 13
celery/result.py

@@ -164,6 +164,7 @@ class TaskSetResult(object):
         A list of :class:`AsyncResult`` instances for all of the subtasks.
 
     """
+
     def __init__(self, taskset_id, subtask_ids):
         self.taskset_id = taskset_id
         self.subtask_ids = subtask_ids
@@ -171,46 +172,46 @@ class TaskSetResult(object):
 
     def itersubtasks(self):
         """Taskset subtask iterator.
-        
+
         :returns: an iterator for iterating over the tasksets
             :class:`AsyncResult` objects.
-        
+
         """
         return (subtask for subtask in self.subtasks)
 
     def successful(self):
         """Was the taskset successful?
-        
+
         :returns: ``True`` if all of the tasks in the taskset finished
             successfully (i.e. did not raise an exception).
-        
+
         """
         return all((subtask.successful()
                         for subtask in self.itersubtasks()))
 
     def failed(self):
         """Did the taskset fail?
-        
+
         :returns: ``True`` if any of the tasks in the taskset failed.
             (i.e., raised an exception)
-            
+
         """
         return any((not subtask.successful()
                         for subtask in self.itersubtasks()))
 
     def waiting(self):
         """Is the taskset waiting?
-        
+
         :returns: ``True`` if any of the tasks in the taskset is still
             waiting for execution.
-            
+
         """
         return any((not subtask.ready()
                         for subtask in self.itersubtasks()))
 
     def ready(self):
-        """Is the task readyu?
-        
+        """Is the task ready?
+
         :returns: ``True`` if all of the tasks in the taskset has been
             executed.
 
@@ -220,9 +221,9 @@ class TaskSetResult(object):
 
     def completed_count(self):
         """Task completion count.
-        
+
         :returns: the number of tasks completed.
-        
+
         """
         return sum(imap(int, (subtask.successful()
                                 for subtask in self.itersubtasks())))
@@ -234,7 +235,7 @@ class TaskSetResult(object):
     def iterate(self):
         """Iterate over the return values of the tasks as they finish
         one by one.
-        
+
         :raises: The exception if any of the tasks raised an exception.
 
         """

+ 10 - 9
celery/worker.py

@@ -18,17 +18,21 @@ import socket
 import time
 import sys
 
+
+# pep8.py borks on a inline signature separator and
+# says "trailing whitespace" ;)
+EMAIL_SIGNATURE_SEP = "-- "
 TASK_FAIL_EMAIL_BODY = """
-Task %(name)s with id %(id)s raised exception: %(exc)s
+Task %%(name)s with id %%(id)s raised exception: %%(exc)s
 
 The contents of the full traceback was:
 
-%(traceback)s
+%%(traceback)s
 
--- 
+%%(EMAIL_SIGNATURE_SEP)s
 Just thought I'd let you know!
-celeryd at %(hostname)s.
-"""
+celeryd at %%(hostname)s.
+""" % {"EMAIL_SIGNATURE_SEP": EMAIL_SIGNATURE_SEP}
 
 
 class EmptyQueue(Exception):
@@ -40,8 +44,6 @@ class UnknownTask(Exception):
     ignored."""
 
 
-
-
 def jail(task_id, func, args, kwargs):
     """Wraps the task in a jail, which catches all exceptions, and
     saves the status and result of the task execution to the task
@@ -125,7 +127,6 @@ class TaskWrapper(object):
     """
     fail_email_body = TASK_FAIL_EMAIL_BODY
 
-
     def __init__(self, task_name, task_id, task_func, args, kwargs, **opts):
         self.task_name = task_name
         self.task_id = task_id
@@ -211,7 +212,7 @@ class TaskWrapper(object):
             "id": task_id,
             "name": task_name,
             "exc": exc_info.exception,
-            "traceback": exc_info.traceback
+            "traceback": exc_info.traceback,
         }
         self.logger.error(self.fail_msg.strip() % context)
 

+ 12 - 2
contrib/testconn.py

@@ -11,6 +11,7 @@ import time
 import multiprocessing
 import logging
 
+
 def get_logger():
     logger = multiprocessing.get_logger()
     logger.setLevel(logging.INFO)
@@ -23,6 +24,7 @@ class MyMessager(Messaging):
     exchange = "conntest"
     routing_key = "conntest"
 
+
 def _create_conn():
     from django.conf import settings
     conn = amqp.Connection(host=settings.AMQP_SERVER,
@@ -32,6 +34,7 @@ def _create_conn():
                            insist=False)
     return conn
 
+
 def _send2(msg):
     conn = _create_conn()
     channel = conn.channel()
@@ -40,6 +43,7 @@ def _send2(msg):
     channel.basic_publish(msg, exchange="conntest", routing_key="conntest")
     conn.close()
 
+
 def _recv2():
     conn = _create_conn()
     channel = conn.channel()
@@ -55,16 +59,19 @@ def _recv2():
         print("RECEIVED MSG: %s" % m.body)
     conn.close()
 
+
 def send_a_message(msg):
     conn = DjangoAMQPConnection()
     MyMessager(connection=conn).send({"message": msg})
     conn.close()
 
+
 def discard_all():
     conn = DjangoAMQPConnection()
     MyMessager(connection=conn).consumer.discard_all()
     conn.close()
 
+
 def receive_a_message():
     logger = get_logger()
     conn = DjangoAMQPConnection()
@@ -75,6 +82,7 @@ def receive_a_message():
         m.ack()
     conn.close()
 
+
 def connection_stress_test():
     message_count = 0
     discard_all()
@@ -85,7 +93,7 @@ def connection_stress_test():
         message_count += 1
         print("Sent %d message(s)" % message_count)
 
-import multiprocessing
+
 def connection_stress_test_mp():
     message_count = 0
     pool = multiprocessing.Pool(10)
@@ -94,10 +102,11 @@ def connection_stress_test_mp():
         pool.apply(send_a_message, ["FOOBARBAZ!!!"])
         time.sleep(0.1)
         r = pool.apply(receive_a_message)
-        
+
         message_count += 1
         print("Sent %d message(s)" % message_count)
 
+
 def connection_stress_test2():
     message_count = 0
     while True:
@@ -107,6 +116,7 @@ def connection_stress_test2():
         message_count += 1
         print("Sent %d message(s)" % message_count)
 
+
 def task_stress_test():
     task_count = 0
     while True:

+ 5 - 1
docs/_ext/applyxrefs.py

@@ -9,11 +9,13 @@ DONT_TOUCH = (
         './index.txt',
         )
 
+
 def target_name(fn):
     if fn.endswith('.txt'):
         fn = fn[:-4]
     return '_' + fn.lstrip('./').replace('/', '-')
 
+
 def process_file(fn, lines):
     lines.insert(0, '\n')
     lines.insert(0, '.. %s:\n' % target_name(fn))
@@ -29,6 +31,7 @@ def process_file(fn, lines):
     finally:
         f.close()
 
+
 def has_target(fn):
     try:
         f = open(fn, 'r')
@@ -54,6 +57,7 @@ def has_target(fn):
         return (True, None)
     return (False, lines)
 
+
 def main(argv=None):
     if argv is None:
         argv = sys.argv
@@ -85,4 +89,4 @@ def main(argv=None):
             print "Skipping %s: already has a xref" % fn
 
 if __name__ == '__main__':
-    sys.exit(main())
+    sys.exit(main())

+ 29 - 22
docs/_ext/djangodocs.py

@@ -11,44 +11,47 @@ import sphinx.environment
 import sphinx.roles
 from docutils import nodes
 
+
 def setup(app):
     app.add_crossref_type(
         directivename = "setting",
-        rolename      = "setting",
+        rolename = "setting",
         indextemplate = "pair: %s; setting",
     )
     app.add_crossref_type(
         directivename = "templatetag",
-        rolename      = "ttag",
-        indextemplate = "pair: %s; template tag"
+        rolename = "ttag",
+        indextemplate = "pair: %s; template tag",
     )
     app.add_crossref_type(
         directivename = "templatefilter",
-        rolename      = "tfilter",
-        indextemplate = "pair: %s; template filter"
+        rolename = "tfilter",
+        indextemplate = "pair: %s; template filter",
     )
     app.add_crossref_type(
         directivename = "fieldlookup",
-        rolename      = "lookup",
+        rolename = "lookup",
         indextemplate = "pair: %s, field lookup type",
     )
     app.add_description_unit(
         directivename = "django-admin",
-        rolename      = "djadmin",
+        rolename = "djadmin",
         indextemplate = "pair: %s; django-admin command",
-        parse_node    = parse_django_admin_node,
+        parse_node = parse_django_admin_node,
     )
     app.add_description_unit(
         directivename = "django-admin-option",
-        rolename      = "djadminopt",
+        rolename = "djadminopt",
         indextemplate = "pair: %s; django-admin command-line option",
-        parse_node    = lambda env, sig, signode: sphinx.directives.parse_option_desc(signode, sig),
+        parse_node = lambda env, sig, signode: \
+                sphinx.directives.parse_option_desc(signode, sig),
     )
     app.add_config_value('django_next_version', '0.0', True)
     app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1))
     app.add_directive('versionchanged', parse_version_directive, 1, (1, 1, 1))
     app.add_transform(SuppressBlockquotes)
 
+
 def parse_version_directive(name, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
     env = state.document.settings.env
@@ -58,8 +61,10 @@ def parse_version_directive(name, arguments, options, content, lineno,
     ret.append(node)
     if not is_nextversion:
         if len(arguments) == 1:
-            linktext = 'Please, see the release notes <releases-%s>' % (arguments[0])
-            xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext, lineno, state)
+            linktext = 'Please, see the release notes <releases-%s>' % (
+                    arguments[0])
+            xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext,
+                                               lineno, state)
             node.extend(xrefs[0])
         node['version'] = arguments[0]
     else:
@@ -74,26 +79,28 @@ def parse_version_directive(name, arguments, options, content, lineno,
     env.note_versionchange(node['type'], node['version'], node, lineno)
     return ret
 
-                
+
 class SuppressBlockquotes(docutils.transforms.Transform):
     """
     Remove the default blockquotes that encase indented list, tables, etc.
     """
     default_priority = 300
-    
+
     suppress_blockquote_child_nodes = (
-        docutils.nodes.bullet_list, 
-        docutils.nodes.enumerated_list, 
+        docutils.nodes.bullet_list,
+        docutils.nodes.enumerated_list,
         docutils.nodes.definition_list,
-        docutils.nodes.literal_block, 
-        docutils.nodes.doctest_block, 
-        docutils.nodes.line_block, 
-        docutils.nodes.table
+        docutils.nodes.literal_block,
+        docutils.nodes.doctest_block,
+        docutils.nodes.line_block,
+        docutils.nodes.table,
     )
-    
+
     def apply(self):
         for node in self.document.traverse(docutils.nodes.block_quote):
-            if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes):
+            if len(node.children) == 1 and \
+                    isinstance(node.children[0],
+                               self.suppress_blockquote_child_nodes):
                 node.replace_self(node.children[0])
 
 

+ 35 - 28
docs/_ext/literals_to_xrefs.py

@@ -19,16 +19,16 @@ ROLES = (
     'func',
     'lookup',
     'meth',
-    'mod' ,
+    'mod',
     "djadminopt",
     "ref",
     "setting",
     "term",
     "tfilter",
     "ttag",
-    
+
     # special
-    "skip"
+    "skip",
 )
 
 ALWAYS_SKIP = [
@@ -37,75 +37,77 @@ ALWAYS_SKIP = [
     "False",
 ]
 
+
 def fixliterals(fname):
     data = open(fname).read()
-    
+
     last = 0
     new = []
     storage = shelve.open("/tmp/literals_to_xref.shelve")
     lastvalues = storage.get("lastvalues", {})
-    
+
     for m in refre.finditer(data):
-        
+
         new.append(data[last:m.start()])
         last = m.end()
-        
+
         line_start = data.rfind("\n", 0, m.start())
         line_end = data.find("\n", m.end())
         prev_start = data.rfind("\n", 0, line_start)
         next_end = data.find("\n", line_end + 1)
-        
+
         # Skip always-skip stuff
         if m.group(1) in ALWAYS_SKIP:
             new.append(m.group(0))
             continue
-            
+
         # skip when the next line is a title
         next_line = data[m.end():next_end].strip()
-        if next_line[0] in "!-/:-@[-`{-~" and all(c == next_line[0] for c in next_line):
+        if next_line[0] in "!-/:-@[-`{-~" and \
+                all(c == next_line[0] for c in next_line):
             new.append(m.group(0))
             continue
-        
+
         sys.stdout.write("\n"+"-"*80+"\n")
         sys.stdout.write(data[prev_start+1:m.start()])
         sys.stdout.write(colorize(m.group(0), fg="red"))
         sys.stdout.write(data[m.end():next_end])
         sys.stdout.write("\n\n")
-        
+
         replace_type = None
         while replace_type is None:
             replace_type = raw_input(
-                colorize("Replace role: ", fg="yellow")
-            ).strip().lower()
+                colorize("Replace role: ", fg="yellow")).strip().lower()
             if replace_type and replace_type not in ROLES:
                 replace_type = None
-        
+
         if replace_type == "":
             new.append(m.group(0))
             continue
-            
+
         if replace_type == "skip":
             new.append(m.group(0))
             ALWAYS_SKIP.append(m.group(1))
             continue
-        
+
         default = lastvalues.get(m.group(1), m.group(1))
-        if default.endswith("()") and replace_type in ("class", "func", "meth"):
-            default = default[:-2]        
+        if default.endswith("()") and \
+                replace_type in ("class", "func", "meth"):
+            default = default[:-2]
         replace_value = raw_input(
-            colorize("Text <target> [", fg="yellow") + default + colorize("]: ", fg="yellow")
-        ).strip()
-        if not replace_value: 
+            colorize("Text <target> [", fg="yellow") + default + \
+                    colorize("]: ", fg="yellow")).strip()
+        if not replace_value:
             replace_value = default
         new.append(":%s:`%s`" % (replace_type, replace_value))
         lastvalues[m.group(1)] = replace_value
-    
+
     new.append(data[last:])
     open(fname, "w").write("".join(new))
-    
+
     storage["lastvalues"] = lastvalues
     storage.close()
-    
+
 #
 # The following is taken from django.utils.termcolors and is copied here to
 # avoid the dependancy.
@@ -141,12 +143,17 @@ def colorize(text='', opts=(), **kwargs):
         print colorize('and so should this')
         print 'this should not be red'
     """
-    color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
+    color_names = ('black', 'red', 'green', 'yellow',
+                   'blue', 'magenta', 'cyan', 'white')
     foreground = dict([(color_names[x], '3%s' % x) for x in range(8)])
     background = dict([(color_names[x], '4%s' % x) for x in range(8)])
 
     RESET = '0'
-    opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
+    opt_dict = {'bold': '1',
+                'underscore': '4',
+                'blink': '5',
+                'reverse': '7',
+                'conceal': '8'}
 
     text = str(text)
     code_list = []
@@ -168,4 +175,4 @@ if __name__ == '__main__':
     try:
         fixliterals(sys.argv[1])
     except (KeyboardInterrupt, SystemExit):
-        print
+        print

+ 0 - 17
docs/conf.py

@@ -1,15 +1,4 @@
 # -*- coding: utf-8 -*-
-#
-# Celery documentation build configuration file, created by
-# sphinx-quickstart on Mon May 18 21:37:44 2009.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# The contents of this file are pickled, so don't put values in the namespace
-# that aren't pickleable (module imports are okay, they're removed automatically).
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
 
 import sys
 import os
@@ -28,8 +17,6 @@ sys.path.append(os.path.join(os.path.dirname(__file__), "_ext"))
 # General configuration
 # ---------------------
 
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.autodoc', 'djangodocs']
 
 # Add any paths that contain templates here, relative to this directory.
@@ -74,8 +61,6 @@ release = celery.version_with_meta()
 # for source files.
 exclude_trees = ['.build']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
 add_function_parentheses = True
@@ -171,8 +156,6 @@ htmlhelp_basename = 'Celerydoc'
 # The font size ('10pt', '11pt' or '12pt').
 #latex_font_size = '10pt'
 
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, document class [howto/manual]).
 latex_documents = [
   ('index', 'Celery.tex', ur'Celery Documentation',
    ur'Ask Solem', 'manual'),

+ 6 - 1
testproj/manage.py

@@ -4,7 +4,12 @@ try:
     import settings # Assumed to be in the same directory.
 except ImportError:
     import sys
-    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.stderr.write(
+            "Error: Can't find the file 'settings.py' in the directory \
+            containing %r. It appears you've customized things.\n\
+            You'll have to run django-admin.py, passing it your settings\
+            module.\n(If the file settings.py does indeed exist, it's\
+            causing an ImportError somehow.)\n" % __file__)
     sys.exit(1)
 
 if __name__ == "__main__":

+ 3 - 3
testproj/settings.py

@@ -31,11 +31,11 @@ CELERY_TASK_META_USE_DB = True
 
 MANAGERS = ADMINS
 
-DATABASE_ENGINE = 'sqlite3'    
-DATABASE_NAME = 'testdb.sqlite' 
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = 'testdb.sqlite'
 DATABASE_USER = ''
 DATABASE_PASSWORD = ''
-DATABASE_HOST = ''             
+DATABASE_HOST = ''
 DATABASE_PORT = ''
 
 INSTALLED_APPS = (

+ 1 - 1
testproj/urls.py

@@ -8,7 +8,7 @@ urlpatterns = patterns('',
     # Example:
     # (r'^testproj/', include('testproj.foo.urls')),
 
-    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
+    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
     # to INSTALLED_APPS to enable admin documentation:
     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),