Commits

Anonymous committed a1e1012

first big fat commit

Comments (0)

Files changed (137)

+syntax: glob
+*.pyc
+*~
+*.DS_Store
+celerybeat-schedule.db
Empty file added.
+"""
+CELERYBEAT_SCHEDULE are task to be run in the background, like cron
+"""
+
+from datetime import timedelta
+from celery.schedules import crontab
+CELERYBEAT_SCHEDULE = {
+#twitfetch tasks. they make call on twitter API to retreive data.
+    "followers-lookup": {
+        "task": "followerslookup.tasks.fetch",
+        "schedule": crontab(minute=12),
+    },
+}

documentation/build/.buildinfo

+# Sphinx build info version 1
+# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
+config: 136e0b76f2f86c9fd500d95b36d52bc1
+tags: fbb0d17656682115ca4d033fb2f83ba1

documentation/build/.doctrees/celery.doctree

Binary file added.

documentation/build/.doctrees/djcelery.doctree

Binary file added.

documentation/build/.doctrees/environment.pickle

Binary file added.

documentation/build/.doctrees/externalapps.doctree

Binary file added.

documentation/build/.doctrees/followerslookup.doctree

Binary file added.

documentation/build/.doctrees/index.doctree

Binary file added.

documentation/build/.doctrees/install.doctree

Binary file added.

documentation/build/.doctrees/social_auth.doctree

Binary file added.

documentation/build/.doctrees/twitter.doctree

Binary file added.

documentation/build/_modules/celery/app.html

+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>celery.app &mdash; EggDiscover 0.1 documentation</title>
+    
+    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
+    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '../../',
+        VERSION:     '0.1',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="../../_static/jquery.js"></script>
+    <script type="text/javascript" src="../../_static/underscore.js"></script>
+    <script type="text/javascript" src="../../_static/doctools.js"></script>
+    <link rel="top" title="EggDiscover 0.1 documentation" href="../../index.html" />
+    <link rel="up" title="Module code" href="../index.html" /> 
+  </head>
+  <body>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body">
+            
+  <h1>Source code for celery.app</h1><div class="highlight"><pre>
+<span class="c"># -*- coding: utf-8 -*-</span>
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    celery.app</span>
+<span class="sd">    ~~~~~~~~~~</span>
+
+<span class="sd">    Celery Application.</span>
+
+<span class="sd">    :copyright: (c) 2009 - 2011 by Ask Solem.</span>
+<span class="sd">    :license: BSD, see LICENSE for more details.</span>
+
+<span class="sd">&quot;&quot;&quot;</span>
+
+<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span>
+
+<span class="kn">import</span> <span class="nn">os</span>
+<span class="kn">import</span> <span class="nn">threading</span>
+
+<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
+<span class="kn">from</span> <span class="nn">inspect</span> <span class="kn">import</span> <span class="n">getargspec</span>
+
+<span class="kn">from</span> <span class="nn">..</span> <span class="kn">import</span> <span class="n">registry</span>
+<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">cached_property</span><span class="p">,</span> <span class="n">instantiate</span>
+
+<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">base</span>
+
+<span class="c"># Apps with the :attr:`~celery.app.base.BaseApp.set_as_current` attribute</span>
+<span class="c"># sets this, so it will always contain the last instantiated app,</span>
+<span class="c"># and is the default app returned by :func:`app_or_default`.</span>
+<span class="n">_tls</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">local</span><span class="p">()</span>
+<span class="n">_tls</span><span class="o">.</span><span class="n">current_app</span> <span class="o">=</span> <span class="bp">None</span>
+
+
+<span class="k">class</span> <span class="nc">AppPickler</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+
+    <span class="k">def</span> <span class="nf">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cls</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
+        <span class="n">kwargs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_kwargs</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
+        <span class="n">app</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">construct</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">prepare</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">app</span>
+
+    <span class="k">def</span> <span class="nf">prepare</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">app</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">kwargs</span><span class="p">[</span><span class="s">&quot;changes&quot;</span><span class="p">])</span>
+
+    <span class="k">def</span> <span class="nf">build_kwargs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_standard_kwargs</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">build_standard_kwargs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">main</span><span class="p">,</span> <span class="n">changes</span><span class="p">,</span> <span class="n">loader</span><span class="p">,</span> <span class="n">backend</span><span class="p">,</span> <span class="n">amqp</span><span class="p">,</span>
+            <span class="n">events</span><span class="p">,</span> <span class="n">log</span><span class="p">,</span> <span class="n">control</span><span class="p">,</span> <span class="n">accept_magic_kwargs</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">dict</span><span class="p">(</span><span class="n">main</span><span class="o">=</span><span class="n">main</span><span class="p">,</span> <span class="n">loader</span><span class="o">=</span><span class="n">loader</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="n">backend</span><span class="p">,</span> <span class="n">amqp</span><span class="o">=</span><span class="n">amqp</span><span class="p">,</span>
+                    <span class="n">changes</span><span class="o">=</span><span class="n">changes</span><span class="p">,</span> <span class="n">events</span><span class="o">=</span><span class="n">events</span><span class="p">,</span> <span class="n">log</span><span class="o">=</span><span class="n">log</span><span class="p">,</span> <span class="n">control</span><span class="o">=</span><span class="n">control</span><span class="p">,</span>
+                    <span class="n">set_as_current</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
+                    <span class="n">accept_magic_kwargs</span><span class="o">=</span><span class="n">accept_magic_kwargs</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">construct</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cls</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="k">return</span> <span class="n">cls</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+
+<span class="k">def</span> <span class="nf">_unpickle_app</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">pickler</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
+    <span class="k">return</span> <span class="n">pickler</span><span class="p">()(</span><span class="n">cls</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
+
+
+<div class="viewcode-block" id="App"><a class="viewcode-back" href="../../celery.html#celery.app.App">[docs]</a><span class="k">class</span> <span class="nc">App</span><span class="p">(</span><span class="n">base</span><span class="o">.</span><span class="n">BaseApp</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Celery Application.</span>
+
+<span class="sd">    :param main: Name of the main module if running as `__main__`.</span>
+<span class="sd">    :keyword loader: The loader class, or the name of the loader class to use.</span>
+<span class="sd">                     Default is :class:`celery.loaders.app.AppLoader`.</span>
+<span class="sd">    :keyword backend: The result store backend class, or the name of the</span>
+<span class="sd">                      backend class to use. Default is the value of the</span>
+<span class="sd">                      :setting:`CELERY_RESULT_BACKEND` setting.</span>
+<span class="sd">    :keyword amqp: AMQP object or class name.</span>
+<span class="sd">    :keyword events: Events object or class name.</span>
+<span class="sd">    :keyword log: Log object or class name.</span>
+<span class="sd">    :keyword control: Control object or class name.</span>
+<span class="sd">    :keyword set_as_current:  Make this the global current app.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="n">Pickler</span> <span class="o">=</span> <span class="n">AppPickler</span>
+
+<div class="viewcode-block" id="App.set_current"><a class="viewcode-back" href="../../celery.html#celery.app.App.set_current">[docs]</a>    <span class="k">def</span> <span class="nf">set_current</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Make this the current app for this thread.&quot;&quot;&quot;</span>
+        <span class="n">_tls</span><span class="o">.</span><span class="n">current_app</span> <span class="o">=</span> <span class="bp">self</span>
+</div>
+    <span class="k">def</span> <span class="nf">on_init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">set_as_current</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">set_current</span><span class="p">()</span>
+
+<div class="viewcode-block" id="App.create_task_cls"><a class="viewcode-back" href="../../celery.html#celery.app.App.create_task_cls">[docs]</a>    <span class="k">def</span> <span class="nf">create_task_cls</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Creates a base task class using default configuration</span>
+<span class="sd">        taken from this app.&quot;&quot;&quot;</span>
+        <span class="n">conf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">conf</span>
+
+        <span class="kn">from</span> <span class="nn">.task</span> <span class="kn">import</span> <span class="n">BaseTask</span>
+
+        <span class="k">class</span> <span class="nc">Task</span><span class="p">(</span><span class="n">BaseTask</span><span class="p">):</span>
+            <span class="n">abstract</span> <span class="o">=</span> <span class="bp">True</span>
+            <span class="n">app</span> <span class="o">=</span> <span class="bp">self</span>
+            <span class="n">backend</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">backend</span>
+            <span class="n">exchange_type</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_DEFAULT_EXCHANGE_TYPE</span>
+            <span class="n">delivery_mode</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_DEFAULT_DELIVERY_MODE</span>
+            <span class="n">send_error_emails</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_SEND_TASK_ERROR_EMAILS</span>
+            <span class="n">error_whitelist</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_TASK_ERROR_WHITELIST</span>
+            <span class="n">serializer</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_TASK_SERIALIZER</span>
+            <span class="n">rate_limit</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_DEFAULT_RATE_LIMIT</span>
+            <span class="n">track_started</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_TRACK_STARTED</span>
+            <span class="n">acks_late</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_ACKS_LATE</span>
+            <span class="n">ignore_result</span> <span class="o">=</span> <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_IGNORE_RESULT</span>
+            <span class="n">store_errors_even_if_ignored</span> <span class="o">=</span> \
+                <span class="n">conf</span><span class="o">.</span><span class="n">CELERY_STORE_ERRORS_EVEN_IF_IGNORED</span>
+            <span class="n">accept_magic_kwargs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">accept_magic_kwargs</span>
+        <span class="n">Task</span><span class="o">.</span><span class="n">__doc__</span> <span class="o">=</span> <span class="n">BaseTask</span><span class="o">.</span><span class="n">__doc__</span>
+
+        <span class="k">return</span> <span class="n">Task</span>
+</div>
+<div class="viewcode-block" id="App.Worker"><a class="viewcode-back" href="../../celery.html#celery.app.App.Worker">[docs]</a>    <span class="k">def</span> <span class="nf">Worker</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Create new :class:`~celery.apps.worker.Worker` instance.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">instantiate</span><span class="p">(</span><span class="s">&quot;celery.apps.worker.Worker&quot;</span><span class="p">,</span> <span class="n">app</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+</div>
+<div class="viewcode-block" id="App.Beat"><a class="viewcode-back" href="../../celery.html#celery.app.App.Beat">[docs]</a>    <span class="k">def</span> <span class="nf">Beat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Create new :class:`~celery.apps.beat.Beat` instance.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="n">instantiate</span><span class="p">(</span><span class="s">&quot;celery.apps.beat.Beat&quot;</span><span class="p">,</span> <span class="n">app</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+</div>
+<div class="viewcode-block" id="App.TaskSet"><a class="viewcode-back" href="../../celery.html#celery.app.App.TaskSet">[docs]</a>    <span class="k">def</span> <span class="nf">TaskSet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Create new :class:`~celery.task.sets.TaskSet`.&quot;&quot;&quot;</span>
+        <span class="kn">from</span> <span class="nn">..task.sets</span> <span class="kn">import</span> <span class="n">TaskSet</span>
+        <span class="n">kwargs</span><span class="p">[</span><span class="s">&quot;app&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
+        <span class="k">return</span> <span class="n">TaskSet</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+</div>
+<div class="viewcode-block" id="App.worker_main"><a class="viewcode-back" href="../../celery.html#celery.app.App.worker_main">[docs]</a>    <span class="k">def</span> <span class="nf">worker_main</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">argv</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Run :program:`celeryd` using `argv`.  Uses :data:`sys.argv`</span>
+<span class="sd">        if `argv` is not specified.&quot;&quot;&quot;</span>
+        <span class="kn">from</span> <span class="nn">..bin.celeryd</span> <span class="kn">import</span> <span class="n">WorkerCommand</span>
+        <span class="k">return</span> <span class="n">WorkerCommand</span><span class="p">(</span><span class="n">app</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">execute_from_commandline</span><span class="p">(</span><span class="n">argv</span><span class="p">)</span>
+</div>
+<div class="viewcode-block" id="App.task"><a class="viewcode-back" href="../../celery.html#celery.app.App.task">[docs]</a>    <span class="k">def</span> <span class="nf">task</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">options</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Decorator to create a task class out of any callable.</span>
+
+<span class="sd">        .. admonition:: Examples</span>
+
+<span class="sd">            .. code-block:: python</span>
+
+<span class="sd">                @task()</span>
+<span class="sd">                def refresh_feed(url):</span>
+<span class="sd">                    return Feed.objects.get(url=url).refresh()</span>
+
+<span class="sd">            With setting extra options and using retry.</span>
+
+<span class="sd">            .. code-block:: python</span>
+
+<span class="sd">                @task(exchange=&quot;feeds&quot;)</span>
+<span class="sd">                def refresh_feed(url, **kwargs):</span>
+<span class="sd">                    try:</span>
+<span class="sd">                        return Feed.objects.get(url=url).refresh()</span>
+<span class="sd">                    except socket.error, exc:</span>
+<span class="sd">                        refresh_feed.retry(args=[url], kwargs=kwargs, exc=exc)</span>
+
+<span class="sd">            Calling the resulting task:</span>
+
+<span class="sd">                &gt;&gt;&gt; refresh_feed(&quot;http://example.com/rss&quot;) # Regular</span>
+<span class="sd">                &lt;Feed: http://example.com/rss&gt;</span>
+<span class="sd">                &gt;&gt;&gt; refresh_feed.delay(&quot;http://example.com/rss&quot;) # Async</span>
+<span class="sd">                &lt;AsyncResult: 8998d0f4-da0b-4669-ba03-d5ab5ac6ad5d&gt;</span>
+
+<span class="sd">        &quot;&quot;&quot;</span>
+
+        <span class="k">def</span> <span class="nf">inner_create_task_cls</span><span class="p">(</span><span class="o">**</span><span class="n">options</span><span class="p">):</span>
+
+            <span class="k">def</span> <span class="nf">_create_task_cls</span><span class="p">(</span><span class="n">fun</span><span class="p">):</span>
+                <span class="n">options</span><span class="p">[</span><span class="s">&quot;app&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
+                <span class="n">options</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s">&quot;accept_magic_kwargs&quot;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
+                <span class="n">base</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s">&quot;base&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">Task</span>
+
+                <span class="nd">@wraps</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">assigned</span><span class="o">=</span><span class="p">(</span><span class="s">&quot;__module__&quot;</span><span class="p">,</span> <span class="s">&quot;__name__&quot;</span><span class="p">))</span>
+                <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+                    <span class="k">return</span> <span class="n">fun</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+                <span class="c"># Save the argspec for this task so we can recognize</span>
+                <span class="c"># which default task kwargs we&#39;re going to pass to it later.</span>
+                <span class="c"># (this happens in celery.utils.fun_takes_kwargs)</span>
+                <span class="n">run</span><span class="o">.</span><span class="n">argspec</span> <span class="o">=</span> <span class="n">getargspec</span><span class="p">(</span><span class="n">fun</span><span class="p">)</span>
+
+                <span class="n">cls_dict</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="n">run</span><span class="o">=</span><span class="n">run</span><span class="p">,</span>
+                                <span class="n">__module__</span><span class="o">=</span><span class="n">fun</span><span class="o">.</span><span class="n">__module__</span><span class="p">,</span>
+                                <span class="n">__doc__</span><span class="o">=</span><span class="n">fun</span><span class="o">.</span><span class="n">__doc__</span><span class="p">)</span>
+                <span class="n">T</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">fun</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="p">),</span> <span class="n">cls_dict</span><span class="p">)()</span>
+                <span class="k">return</span> <span class="n">registry</span><span class="o">.</span><span class="n">tasks</span><span class="p">[</span><span class="n">T</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>             <span class="c"># global instance.</span>
+
+            <span class="k">return</span> <span class="n">_create_task_cls</span>
+
+        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">callable</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
+            <span class="k">return</span> <span class="n">inner_create_task_cls</span><span class="p">(</span><span class="o">**</span><span class="n">options</span><span class="p">)(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">inner_create_task_cls</span><span class="p">(</span><span class="o">**</span><span class="n">options</span><span class="p">)</span>
+</div>
+    <span class="nd">@cached_property</span>
+<div class="viewcode-block" id="App.Task"><a class="viewcode-back" href="../../celery.html#celery.app.App.Task">[docs]</a>    <span class="k">def</span> <span class="nf">Task</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Default Task base class for this application.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_task_cls</span><span class="p">()</span>
+</div>
+    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="s">&quot;&lt;Celery: </span><span class="si">%s</span><span class="s">:0x</span><span class="si">%x</span><span class="s">&gt;&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">main</span> <span class="ow">or</span> <span class="s">&quot;__main__&quot;</span><span class="p">,</span> <span class="nb">id</span><span class="p">(</span><span class="bp">self</span><span class="p">),</span> <span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__reduce__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="c"># Reduce only pickles the configuration changes,</span>
+        <span class="c"># so the default configuration doesn&#39;t have to be passed</span>
+        <span class="c"># between processes.</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">_unpickle_app</span><span class="p">,</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Pickler</span><span class="p">)</span>
+                              <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">__reduce_args__</span><span class="p">())</span>
+
+    <span class="k">def</span> <span class="nf">__reduce_args__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">main</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">changes</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">loader_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">backend_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">amqp_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">events_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">log_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">control_cls</span><span class="p">,</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">accept_magic_kwargs</span><span class="p">)</span>
+
+
+<span class="c">#: The &quot;default&quot; loader is the default loader used by old applications.</span></div>
+<span class="n">default_loader</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;CELERY_LOADER&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="s">&quot;default&quot;</span>
+
+<span class="c">#: Global fallback app instance.</span>
+<span class="n">default_app</span> <span class="o">=</span> <span class="n">App</span><span class="p">(</span><span class="s">&quot;default&quot;</span><span class="p">,</span> <span class="n">loader</span><span class="o">=</span><span class="n">default_loader</span><span class="p">,</span>
+                  <span class="n">set_as_current</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">accept_magic_kwargs</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+
+
+<span class="k">def</span> <span class="nf">current_app</span><span class="p">():</span>
+    <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">_tls</span><span class="p">,</span> <span class="s">&quot;current_app&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">or</span> <span class="n">default_app</span>
+
+
+<span class="k">def</span> <span class="nf">_app_or_default</span><span class="p">(</span><span class="n">app</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Returns the app provided or the default app if none.</span>
+
+<span class="sd">    The environment variable :envvar:`CELERY_TRACE_APP` is used to</span>
+<span class="sd">    trace app leaks.  When enabled an exception is raised if there</span>
+<span class="sd">    is no active app.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">if</span> <span class="n">app</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">_tls</span><span class="p">,</span> <span class="s">&quot;current_app&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">or</span> <span class="n">default_app</span>
+    <span class="k">return</span> <span class="n">app</span>
+
+
+<span class="k">def</span> <span class="nf">_app_or_default_trace</span><span class="p">(</span><span class="n">app</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>  <span class="c"># pragma: no cover</span>
+    <span class="kn">from</span> <span class="nn">traceback</span> <span class="kn">import</span> <span class="n">print_stack</span>
+    <span class="kn">from</span> <span class="nn">multiprocessing</span> <span class="kn">import</span> <span class="n">current_process</span>
+    <span class="k">if</span> <span class="n">app</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+        <span class="k">if</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">_tls</span><span class="p">,</span> <span class="s">&quot;current_app&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">):</span>
+            <span class="k">print</span><span class="p">(</span><span class="s">&quot;-- RETURNING TO CURRENT APP --&quot;</span><span class="p">)</span>  <span class="c"># noqa+</span>
+            <span class="n">print_stack</span><span class="p">()</span>
+            <span class="k">return</span> <span class="n">_tls</span><span class="o">.</span><span class="n">current_app</span>
+        <span class="k">if</span> <span class="n">current_process</span><span class="p">()</span><span class="o">.</span><span class="n">_name</span> <span class="o">==</span> <span class="s">&quot;MainProcess&quot;</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&quot;DEFAULT APP&quot;</span><span class="p">)</span>
+        <span class="k">print</span><span class="p">(</span><span class="s">&quot;-- RETURNING TO DEFAULT APP --&quot;</span><span class="p">)</span>      <span class="c"># noqa+</span>
+        <span class="n">print_stack</span><span class="p">()</span>
+        <span class="k">return</span> <span class="n">default_app</span>
+    <span class="k">return</span> <span class="n">app</span>
+
+
+<span class="k">def</span> <span class="nf">enable_trace</span><span class="p">():</span>
+    <span class="k">global</span> <span class="n">app_or_default</span>
+    <span class="n">app_or_default</span> <span class="o">=</span> <span class="n">_app_or_default_trace</span>
+
+
+<span class="k">def</span> <span class="nf">disable_trace</span><span class="p">():</span>
+    <span class="k">global</span> <span class="n">app_or_default</span>
+    <span class="n">app_or_default</span> <span class="o">=</span> <span class="n">_app_or_default</span>
+
+
+<span class="n">app_or_default</span> <span class="o">=</span> <span class="n">_app_or_default</span>
+<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;CELERY_TRACE_APP&quot;</span><span class="p">):</span>  <span class="c"># pragma: no cover</span>
+    <span class="n">enable_trace</span><span class="p">()</span>
+</pre></div>
+
+          </div>
+        </div>
+      </div>
+      <div class="sphinxsidebar">
+        <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none">
+  <h3>Quick search</h3>
+    <form class="search" action="../../search.html" method="get">
+      <input type="text" name="q" />
+      <input type="submit" value="Go" />
+      <input type="hidden" name="check_keywords" value="yes" />
+      <input type="hidden" name="area" value="default" />
+    </form>
+    <p class="searchtip" style="font-size: 90%">
+    Enter search terms or a module, class or function name.
+    </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" >Module code</a> &raquo;</li> 
+      </ul>
+    </div>
+    <div class="footer">
+        &copy; Copyright 2012, Yohann Gabory.
+      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
+    </div>
+  </body>
+</html>

documentation/build/_modules/celery/backends.html

+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>celery.backends &mdash; EggDiscover 0.1 documentation</title>
+    
+    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
+    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '../../',
+        VERSION:     '0.1',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="../../_static/jquery.js"></script>
+    <script type="text/javascript" src="../../_static/underscore.js"></script>
+    <script type="text/javascript" src="../../_static/doctools.js"></script>
+    <link rel="top" title="EggDiscover 0.1 documentation" href="../../index.html" />
+    <link rel="up" title="Module code" href="../index.html" /> 
+  </head>
+  <body>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body">
+            
+  <h1>Source code for celery.backends</h1><div class="highlight"><pre>
+<span class="c"># -*- coding: utf-8 -*-</span>
+<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span>
+
+<span class="kn">from</span> <span class="nn">..</span> <span class="kn">import</span> <span class="n">current_app</span>
+<span class="kn">from</span> <span class="nn">..local</span> <span class="kn">import</span> <span class="n">Proxy</span>
+<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">get_cls_by_name</span>
+<span class="kn">from</span> <span class="nn">..utils.functional</span> <span class="kn">import</span> <span class="n">memoize</span>
+
+<span class="n">BACKEND_ALIASES</span> <span class="o">=</span> <span class="p">{</span>
+    <span class="s">&quot;amqp&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.amqp.AMQPBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;cache&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.cache.CacheBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;redis&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.redis.RedisBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;mongodb&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.mongodb.MongoBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;tyrant&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.tyrant.TyrantBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;database&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.database.DatabaseBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;cassandra&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.cassandra.CassandraBackend&quot;</span><span class="p">,</span>
+    <span class="s">&quot;disabled&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backends.base.DisabledBackend&quot;</span><span class="p">,</span>
+<span class="p">}</span>
+
+
+<span class="nd">@memoize</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
+<div class="viewcode-block" id="get_backend_cls"><a class="viewcode-back" href="../../celery.html#celery.backends.get_backend_cls">[docs]</a><span class="k">def</span> <span class="nf">get_backend_cls</span><span class="p">(</span><span class="n">backend</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">loader</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Get backend class by name/alias&quot;&quot;&quot;</span>
+    <span class="n">backend</span> <span class="o">=</span> <span class="n">backend</span> <span class="ow">or</span> <span class="s">&quot;disabled&quot;</span>
+    <span class="n">loader</span> <span class="o">=</span> <span class="n">loader</span> <span class="ow">or</span> <span class="n">current_app</span><span class="o">.</span><span class="n">loader</span>
+    <span class="n">aliases</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">BACKEND_ALIASES</span><span class="p">,</span> <span class="o">**</span><span class="n">loader</span><span class="o">.</span><span class="n">override_backends</span><span class="p">)</span>
+    <span class="k">try</span><span class="p">:</span>
+        <span class="k">return</span> <span class="n">get_cls_by_name</span><span class="p">(</span><span class="n">backend</span><span class="p">,</span> <span class="n">aliases</span><span class="p">)</span>
+    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
+        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;Unknown result backend: </span><span class="si">%r</span><span class="s">.  &quot;</span>
+                         <span class="s">&quot;Did you spell it correctly?  (</span><span class="si">%s</span><span class="s">)&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">backend</span><span class="p">,</span> <span class="n">exc</span><span class="p">))</span>
+
+
+<span class="c"># deprecate this.</span></div>
+<span class="n">default_backend</span> <span class="o">=</span> <span class="n">Proxy</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="n">current_app</span><span class="o">.</span><span class="n">backend</span><span class="p">)</span>
+</pre></div>
+
+          </div>
+        </div>
+      </div>
+      <div class="sphinxsidebar">
+        <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none">
+  <h3>Quick search</h3>
+    <form class="search" action="../../search.html" method="get">
+      <input type="text" name="q" />
+      <input type="submit" value="Go" />
+      <input type="hidden" name="check_keywords" value="yes" />
+      <input type="hidden" name="area" value="default" />
+    </form>
+    <p class="searchtip" style="font-size: 90%">
+    Enter search terms or a module, class or function name.
+    </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" >Module code</a> &raquo;</li> 
+      </ul>
+    </div>
+    <div class="footer">
+        &copy; Copyright 2012, Yohann Gabory.
+      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
+    </div>
+  </body>
+</html>

documentation/build/_modules/celery/beat.html

+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>celery.beat &mdash; EggDiscover 0.1 documentation</title>
+    
+    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
+    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '../../',
+        VERSION:     '0.1',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="../../_static/jquery.js"></script>
+    <script type="text/javascript" src="../../_static/underscore.js"></script>
+    <script type="text/javascript" src="../../_static/doctools.js"></script>
+    <link rel="top" title="EggDiscover 0.1 documentation" href="../../index.html" />
+    <link rel="up" title="Module code" href="../index.html" /> 
+  </head>
+  <body>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body">
+            
+  <h1>Source code for celery.beat</h1><div class="highlight"><pre>
+<span class="c"># -*- coding: utf-8 -*-</span>
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    celery.beat</span>
+<span class="sd">    ~~~~~~~~~~~</span>
+
+<span class="sd">    The Celery periodic task scheduler.</span>
+
+<span class="sd">    :copyright: (c) 2009 - 2011 by Ask Solem.</span>
+<span class="sd">    :license: BSD, see LICENSE for more details.</span>
+
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span>
+
+<span class="kn">import</span> <span class="nn">errno</span>
+<span class="kn">import</span> <span class="nn">os</span>
+<span class="kn">import</span> <span class="nn">time</span>
+<span class="kn">import</span> <span class="nn">shelve</span>
+<span class="kn">import</span> <span class="nn">sys</span>
+<span class="kn">import</span> <span class="nn">threading</span>
+<span class="kn">import</span> <span class="nn">traceback</span>
+<span class="k">try</span><span class="p">:</span>
+    <span class="kn">import</span> <span class="nn">multiprocessing</span>
+<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
+    <span class="n">multiprocessing</span> <span class="o">=</span> <span class="bp">None</span>  <span class="c"># noqa</span>
+
+<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
+
+<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">__version__</span>
+<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">platforms</span>
+<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">registry</span>
+<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">signals</span>
+<span class="kn">from</span> <span class="nn">.app</span> <span class="kn">import</span> <span class="n">app_or_default</span>
+<span class="kn">from</span> <span class="nn">.log</span> <span class="kn">import</span> <span class="n">SilenceRepeated</span>
+<span class="kn">from</span> <span class="nn">.schedules</span> <span class="kn">import</span> <span class="n">maybe_schedule</span><span class="p">,</span> <span class="n">crontab</span>
+<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">cached_property</span><span class="p">,</span> <span class="n">instantiate</span><span class="p">,</span> <span class="n">maybe_promise</span>
+<span class="kn">from</span> <span class="nn">.utils.timeutils</span> <span class="kn">import</span> <span class="n">humanize_seconds</span>
+
+
+<div class="viewcode-block" id="SchedulingError"><a class="viewcode-back" href="../../celery.html#celery.beat.SchedulingError">[docs]</a><span class="k">class</span> <span class="nc">SchedulingError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;An error occured while scheduling a task.&quot;&quot;&quot;</span>
+
+</div>
+<div class="viewcode-block" id="ScheduleEntry"><a class="viewcode-back" href="../../celery.html#celery.beat.ScheduleEntry">[docs]</a><span class="k">class</span> <span class="nc">ScheduleEntry</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;An entry in the scheduler.</span>
+
+<span class="sd">    :keyword name: see :attr:`name`.</span>
+<span class="sd">    :keyword schedule: see :attr:`schedule`.</span>
+<span class="sd">    :keyword args: see :attr:`args`.</span>
+<span class="sd">    :keyword kwargs: see :attr:`kwargs`.</span>
+<span class="sd">    :keyword options: see :attr:`options`.</span>
+<span class="sd">    :keyword last_run_at: see :attr:`last_run_at`.</span>
+<span class="sd">    :keyword total_run_count: see :attr:`total_run_count`.</span>
+<span class="sd">    :keyword relative: Is the time relative to when the server starts?</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="c">#: The task name</span>
+    <span class="n">name</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: The schedule (run_every/crontab)</span>
+    <span class="n">schedule</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Positional arguments to apply.</span>
+    <span class="n">args</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Keyword arguments to apply.</span>
+    <span class="n">kwargs</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Task execution options.</span>
+    <span class="n">options</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: The time and date of when this task was last scheduled.</span>
+    <span class="n">last_run_at</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Total number of times this task has been scheduled.</span>
+    <span class="n">total_run_count</span> <span class="o">=</span> <span class="mi">0</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">task</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">last_run_at</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
+            <span class="n">total_run_count</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">schedule</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="p">(),</span> <span class="n">kwargs</span><span class="o">=</span><span class="p">{},</span>
+            <span class="n">options</span><span class="o">=</span><span class="p">{},</span> <span class="n">relative</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">task</span> <span class="o">=</span> <span class="n">task</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">args</span> <span class="o">=</span> <span class="n">args</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="n">options</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span> <span class="o">=</span> <span class="n">maybe_schedule</span><span class="p">(</span><span class="n">schedule</span><span class="p">,</span> <span class="n">relative</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">last_run_at</span> <span class="o">=</span> <span class="n">last_run_at</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_default_now</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">total_run_count</span> <span class="o">=</span> <span class="n">total_run_count</span> <span class="ow">or</span> <span class="mi">0</span>
+
+    <span class="k">def</span> <span class="nf">_default_now</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">_next_instance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">last_run_at</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Returns a new instance of the same class, but with</span>
+<span class="sd">        its date and count fields updated.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="p">(</span><span class="o">**</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
+                                     <span class="n">last_run_at</span><span class="o">=</span><span class="n">last_run_at</span> <span class="ow">or</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span>
+                                     <span class="n">total_run_count</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">total_run_count</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span>
+    <span class="n">__next__</span> <span class="o">=</span> <span class="nb">next</span> <span class="o">=</span> <span class="n">_next_instance</span>  <span class="c"># for 2to3</span>
+
+<div class="viewcode-block" id="ScheduleEntry.update"><a class="viewcode-back" href="../../celery.html#celery.beat.ScheduleEntry.update">[docs]</a>    <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Update values from another entry.</span>
+
+<span class="sd">        Does only update &quot;editable&quot; fields (task, schedule, args, kwargs,</span>
+<span class="sd">        options).</span>
+
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">__dict__</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s">&quot;task&quot;</span><span class="p">:</span> <span class="n">other</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="s">&quot;schedule&quot;</span><span class="p">:</span> <span class="n">other</span><span class="o">.</span><span class="n">schedule</span><span class="p">,</span>
+                              <span class="s">&quot;args&quot;</span><span class="p">:</span> <span class="n">other</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="s">&quot;kwargs&quot;</span><span class="p">:</span> <span class="n">other</span><span class="o">.</span><span class="n">kwargs</span><span class="p">,</span>
+                              <span class="s">&quot;options&quot;</span><span class="p">:</span> <span class="n">other</span><span class="o">.</span><span class="n">options</span><span class="p">})</span>
+</div>
+<div class="viewcode-block" id="ScheduleEntry.is_due"><a class="viewcode-back" href="../../celery.html#celery.beat.ScheduleEntry.is_due">[docs]</a>    <span class="k">def</span> <span class="nf">is_due</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;See :meth:`celery.task.base.PeriodicTask.is_due`.&quot;&quot;&quot;</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="o">.</span><span class="n">is_due</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">last_run_at</span><span class="p">)</span>
+</div>
+    <span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="p">(</span><span class="s">&quot;&lt;Entry: </span><span class="si">%(name)s</span><span class="s"> </span><span class="si">%(task)s</span><span class="s">(*</span><span class="si">%(args)s</span><span class="s">, **</span><span class="si">%(kwargs)s</span><span class="s">) &quot;</span>
+                <span class="s">&quot;{</span><span class="si">%(schedule)s</span><span class="s">}&gt;&quot;</span> <span class="o">%</span> <span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
+
+</div>
+<div class="viewcode-block" id="Scheduler"><a class="viewcode-back" href="../../celery.html#celery.beat.Scheduler">[docs]</a><span class="k">class</span> <span class="nc">Scheduler</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Scheduler for periodic tasks.</span>
+
+<span class="sd">    :keyword schedule: see :attr:`schedule`.</span>
+<span class="sd">    :keyword logger: see :attr:`logger`.</span>
+<span class="sd">    :keyword max_interval: see :attr:`max_interval`.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="n">Entry</span> <span class="o">=</span> <span class="n">ScheduleEntry</span>
+
+    <span class="c">#: The schedule dict/shelve.</span>
+    <span class="n">schedule</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Current logger.</span>
+    <span class="n">logger</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Maximum time to sleep between re-checking the schedule.</span>
+    <span class="n">max_interval</span> <span class="o">=</span> <span class="mi">1</span>
+
+    <span class="c">#: How often to sync the schedule (3 minutes by default)</span>
+    <span class="n">sync_every</span> <span class="o">=</span> <span class="mi">3</span> <span class="o">*</span> <span class="mi">60</span>
+
+    <span class="n">_last_sync</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schedule</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">logger</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">max_interval</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
+            <span class="n">app</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">Publisher</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="n">app</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span> <span class="o">=</span> <span class="n">app_or_default</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">maybe_promise</span><span class="p">({}</span> <span class="k">if</span> <span class="n">schedule</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">schedule</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logger</span> <span class="ow">or</span> <span class="n">app</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">get_default_logger</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;celery.beat&quot;</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">max_interval</span> <span class="o">=</span> <span class="n">max_interval</span> <span class="ow">or</span> \
+                                <span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">CELERYBEAT_MAX_LOOP_INTERVAL</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">Publisher</span> <span class="o">=</span> <span class="n">Publisher</span> <span class="ow">or</span> <span class="n">app</span><span class="o">.</span><span class="n">amqp</span><span class="o">.</span><span class="n">TaskPublisher</span>
+        <span class="k">if</span> <span class="ow">not</span> <span class="n">lazy</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">setup_schedule</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">install_default_entries</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
+        <span class="n">entries</span> <span class="o">=</span> <span class="p">{}</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">CELERY_TASK_RESULT_EXPIRES</span><span class="p">:</span>
+            <span class="k">if</span> <span class="s">&quot;celery.backend_cleanup&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
+                <span class="n">entries</span><span class="p">[</span><span class="s">&quot;celery.backend_cleanup&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
+                        <span class="s">&quot;task&quot;</span><span class="p">:</span> <span class="s">&quot;celery.backend_cleanup&quot;</span><span class="p">,</span>
+                        <span class="s">&quot;schedule&quot;</span><span class="p">:</span> <span class="n">crontab</span><span class="p">(</span><span class="s">&quot;0&quot;</span><span class="p">,</span> <span class="s">&quot;4&quot;</span><span class="p">,</span> <span class="s">&quot;*&quot;</span><span class="p">),</span>
+                        <span class="s">&quot;options&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s">&quot;expires&quot;</span><span class="p">:</span> <span class="mi">12</span> <span class="o">*</span> <span class="mi">3600</span><span class="p">}}</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">update_from_dict</span><span class="p">(</span><span class="n">entries</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">maybe_due</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">entry</span><span class="p">,</span> <span class="n">publisher</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="n">is_due</span><span class="p">,</span> <span class="n">next_time_to_run</span> <span class="o">=</span> <span class="n">entry</span><span class="o">.</span><span class="n">is_due</span><span class="p">()</span>
+
+        <span class="k">if</span> <span class="n">is_due</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Scheduler: Sending due task </span><span class="si">%s</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">task</span><span class="p">)</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_async</span><span class="p">(</span><span class="n">entry</span><span class="p">,</span> <span class="n">publisher</span><span class="o">=</span><span class="n">publisher</span><span class="p">)</span>
+            <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&quot;Message Error: </span><span class="si">%s</span><span class="se">\n</span><span class="si">%s</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">exc</span><span class="p">,</span>
+                                  <span class="n">traceback</span><span class="o">.</span><span class="n">format_stack</span><span class="p">(),</span>
+                                  <span class="n">exc_info</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">())</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> sent. id-&gt;</span><span class="si">%s</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">task</span><span class="p">,</span>
+                                                     <span class="n">result</span><span class="o">.</span><span class="n">task_id</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">next_time_to_run</span>
+
+<div class="viewcode-block" id="Scheduler.tick"><a class="viewcode-back" href="../../celery.html#celery.beat.Scheduler.tick">[docs]</a>    <span class="k">def</span> <span class="nf">tick</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Run a tick, that is one iteration of the scheduler.</span>
+
+<span class="sd">        Executes all due tasks.</span>
+
+<span class="sd">        &quot;&quot;&quot;</span>
+        <span class="n">remaining_times</span> <span class="o">=</span> <span class="p">[]</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="o">.</span><span class="n">itervalues</span><span class="p">():</span>
+                <span class="n">next_time_to_run</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_due</span><span class="p">(</span><span class="n">entry</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">publisher</span><span class="p">)</span>
+                <span class="k">if</span> <span class="n">next_time_to_run</span><span class="p">:</span>
+                    <span class="n">remaining_times</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">next_time_to_run</span><span class="p">)</span>
+        <span class="k">except</span> <span class="ne">RuntimeError</span><span class="p">:</span>
+            <span class="k">pass</span>
+
+        <span class="k">return</span> <span class="nb">min</span><span class="p">(</span><span class="n">remaining_times</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">max_interval</span><span class="p">])</span>
+</div>
+    <span class="k">def</span> <span class="nf">should_sync</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_last_sync</span> <span class="ow">or</span>
+                <span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">_last_sync</span><span class="p">)</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">sync_every</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">reserve</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">entry</span><span class="p">):</span>
+        <span class="n">new_entry</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="p">[</span><span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">entry</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
+        <span class="k">return</span> <span class="n">new_entry</span>
+
+    <span class="k">def</span> <span class="nf">apply_async</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">entry</span><span class="p">,</span> <span class="n">publisher</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="c"># Update timestamps and run counts before we actually execute,</span>
+        <span class="c"># so we have that done if an exception is raised (doesn&#39;t schedule</span>
+        <span class="c"># forever.)</span>
+        <span class="n">entry</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">reserve</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
+        <span class="n">task</span> <span class="o">=</span> <span class="n">registry</span><span class="o">.</span><span class="n">tasks</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">task</span><span class="p">)</span>
+
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">task</span><span class="p">:</span>
+                <span class="n">result</span> <span class="o">=</span> <span class="n">task</span><span class="o">.</span><span class="n">apply_async</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">kwargs</span><span class="p">,</span>
+                                          <span class="n">publisher</span><span class="o">=</span><span class="n">publisher</span><span class="p">,</span>
+                                          <span class="o">**</span><span class="n">entry</span><span class="o">.</span><span class="n">options</span><span class="p">)</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">send_task</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">kwargs</span><span class="p">,</span>
+                                        <span class="n">publisher</span><span class="o">=</span><span class="n">publisher</span><span class="p">,</span>
+                                        <span class="o">**</span><span class="n">entry</span><span class="o">.</span><span class="n">options</span><span class="p">)</span>
+        <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="n">SchedulingError</span><span class="p">(</span><span class="s">&quot;Couldn&#39;t apply scheduled task </span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span>
+                    <span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">exc</span><span class="p">))</span>
+
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">should_sync</span><span class="p">():</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_do_sync</span><span class="p">()</span>
+        <span class="k">return</span> <span class="n">result</span>
+
+    <span class="k">def</span> <span class="nf">send_task</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>               <span class="c"># pragma: no cover</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">send_task</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">setup_schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">install_default_entries</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_do_sync</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Celerybeat: Synchronizing schedule...&quot;</span><span class="p">)</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+        <span class="k">finally</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_last_sync</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">sync</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">pass</span>
+
+    <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="n">entry</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Entry</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="p">[</span><span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">entry</span>
+        <span class="k">return</span> <span class="n">entry</span>
+
+    <span class="k">def</span> <span class="nf">_maybe_entry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">entry</span><span class="p">):</span>
+        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">entry</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Entry</span><span class="p">):</span>
+            <span class="k">return</span> <span class="n">entry</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Entry</span><span class="p">(</span><span class="o">**</span><span class="nb">dict</span><span class="p">(</span><span class="n">entry</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">))</span>
+
+    <span class="k">def</span> <span class="nf">update_from_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dict_</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="nb">dict</span><span class="p">((</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_maybe_entry</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">entry</span><span class="p">))</span>
+                                <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">dict_</span><span class="o">.</span><span class="n">items</span><span class="p">()))</span>
+
+    <span class="k">def</span> <span class="nf">merge_inplace</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
+        <span class="n">schedule</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schedule</span>
+        <span class="n">A</span><span class="p">,</span> <span class="n">B</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">schedule</span><span class="o">.</span><span class="n">keys</span><span class="p">()),</span> <span class="nb">set</span><span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
+
+        <span class="c"># Remove items from disk not in the schedule anymore.</span>
+        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">A</span> <span class="o">^</span> <span class="n">B</span><span class="p">:</span>
+            <span class="n">schedule</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
+
+        <span class="c"># Update and add new items in the schedule</span>
+        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">B</span><span class="p">:</span>
+            <span class="n">entry</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Entry</span><span class="p">(</span><span class="o">**</span><span class="nb">dict</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="n">key</span><span class="p">))</span>
+            <span class="k">if</span> <span class="n">schedule</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">):</span>
+                <span class="n">schedule</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
+            <span class="k">else</span><span class="p">:</span>
+                <span class="n">schedule</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">entry</span>
+
+    <span class="k">def</span> <span class="nf">get_schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span>
+
+    <span class="k">def</span> <span class="nf">set_schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schedule</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">schedule</span>
+
+    <span class="k">def</span> <span class="nf">_ensure_connected</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="c"># callback called for each retry while the connection</span>
+        <span class="c"># can&#39;t be established.</span>
+        <span class="k">def</span> <span class="nf">_error_handler</span><span class="p">(</span><span class="n">exc</span><span class="p">,</span> <span class="n">interval</span><span class="p">):</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&quot;Celerybeat: Connection error: </span><span class="si">%s</span><span class="s">. &quot;</span>
+                              <span class="s">&quot;Trying again in </span><span class="si">%s</span><span class="s"> seconds...&quot;</span><span class="p">,</span> <span class="n">exc</span><span class="p">,</span> <span class="n">interval</span><span class="p">)</span>
+
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">ensure_connection</span><span class="p">(</span><span class="n">_error_handler</span><span class="p">,</span>
+                    <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">BROKER_CONNECTION_MAX_RETRIES</span><span class="p">)</span>
+
+    <span class="nd">@cached_property</span>
+    <span class="k">def</span> <span class="nf">connection</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">broker_connection</span><span class="p">()</span>
+
+    <span class="nd">@cached_property</span>
+    <span class="k">def</span> <span class="nf">publisher</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Publisher</span><span class="p">(</span><span class="n">connection</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_connected</span><span class="p">())</span>
+
+    <span class="nd">@property</span>
+<div class="viewcode-block" id="Scheduler.schedule"><a class="viewcode-back" href="../../celery.html#celery.beat.Scheduler.schedule">[docs]</a>    <span class="k">def</span> <span class="nf">schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_schedule</span><span class="p">()</span>
+</div>
+    <span class="nd">@property</span>
+    <span class="k">def</span> <span class="nf">info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="s">&quot;&quot;</span>
+
+</div>
+<span class="k">class</span> <span class="nc">PersistentScheduler</span><span class="p">(</span><span class="n">Scheduler</span><span class="p">):</span>
+    <span class="n">persistence</span> <span class="o">=</span> <span class="n">shelve</span>
+
+    <span class="n">_store</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;schedule_filename&quot;</span><span class="p">)</span>
+        <span class="n">Scheduler</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_remove_db</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">for</span> <span class="n">suffix</span> <span class="ow">in</span> <span class="s">&quot;&quot;</span><span class="p">,</span> <span class="s">&quot;.db&quot;</span><span class="p">,</span> <span class="s">&quot;.dat&quot;</span><span class="p">,</span> <span class="s">&quot;.bak&quot;</span><span class="p">,</span> <span class="s">&quot;.dir&quot;</span><span class="p">:</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span> <span class="o">+</span> <span class="n">suffix</span><span class="p">)</span>
+            <span class="k">except</span> <span class="ne">OSError</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
+                <span class="k">if</span> <span class="n">exc</span><span class="o">.</span><span class="n">errno</span> <span class="o">!=</span> <span class="n">errno</span><span class="o">.</span><span class="n">ENOENT</span><span class="p">:</span>
+                    <span class="k">raise</span>
+
+    <span class="k">def</span> <span class="nf">setup_schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_store</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span><span class="p">,</span>
+                                                <span class="n">writeback</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+            <span class="n">entries</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s">&quot;entries&quot;</span><span class="p">,</span> <span class="p">{})</span>
+        <span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&quot;Removing corrupted schedule file </span><span class="si">%r</span><span class="s">: </span><span class="si">%r</span><span class="s">&quot;</span><span class="p">,</span>
+                              <span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span><span class="p">,</span> <span class="n">exc</span><span class="p">,</span> <span class="n">exc_info</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_remove_db</span><span class="p">()</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_store</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span><span class="p">,</span>
+                                                <span class="n">writeback</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="k">if</span> <span class="s">&quot;__version__&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="p">:</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>   <span class="c"># remove schedule at 2.2.2 upgrade.</span>
+        <span class="n">entries</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s">&quot;entries&quot;</span><span class="p">,</span> <span class="p">{})</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">merge_inplace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">CELERYBEAT_SCHEDULE</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">install_default_entries</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">schedule</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="p">[</span><span class="s">&quot;__version__&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">__version__</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Current schedule:</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">+</span>
+                          <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
+                                    <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="o">.</span><span class="n">itervalues</span><span class="p">()))</span>
+
+    <span class="k">def</span> <span class="nf">get_schedule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="p">[</span><span class="s">&quot;entries&quot;</span><span class="p">]</span>
+
+    <span class="k">def</span> <span class="nf">sync</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_store</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_store</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+
+    <span class="nd">@property</span>
+    <span class="k">def</span> <span class="nf">info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="s">&quot;    . db -&gt; </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span><span class="p">,</span> <span class="p">)</span>
+
+
+<span class="k">class</span> <span class="nc">Service</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="n">scheduler_cls</span> <span class="o">=</span> <span class="n">PersistentScheduler</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">logger</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">max_interval</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">schedule_filename</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
+            <span class="n">scheduler_cls</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">app</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="n">app</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span> <span class="o">=</span> <span class="n">app_or_default</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">max_interval</span> <span class="o">=</span> <span class="n">max_interval</span> <span class="ow">or</span> \
+                                <span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">CELERYBEAT_MAX_LOOP_INTERVAL</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">scheduler_cls</span> <span class="o">=</span> <span class="n">scheduler_cls</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">scheduler_cls</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logger</span> <span class="ow">or</span> <span class="n">app</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">get_default_logger</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;celery.beat&quot;</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span> <span class="o">=</span> <span class="n">schedule_filename</span> <span class="ow">or</span> \
+                                    <span class="n">app</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">CELERYBEAT_SCHEDULE_FILENAME</span>
+
+        <span class="bp">self</span><span class="o">.</span><span class="n">_is_shutdown</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_is_stopped</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="n">SilenceRepeated</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span>
+                        <span class="mi">10</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_interval</span> <span class="o">&lt;</span> <span class="mi">60</span> <span class="k">else</span> <span class="mi">1</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">embedded_process</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Celerybeat: Starting...&quot;</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Celerybeat: Ticking with max interval-&gt;</span><span class="si">%s</span><span class="s">&quot;</span><span class="p">,</span>
+                          <span class="n">humanize_seconds</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">max_interval</span><span class="p">))</span>
+
+        <span class="n">signals</span><span class="o">.</span><span class="n">beat_init</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sender</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
+        <span class="k">if</span> <span class="n">embedded_process</span><span class="p">:</span>
+            <span class="n">signals</span><span class="o">.</span><span class="n">beat_embedded_init</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sender</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>
+            <span class="n">platforms</span><span class="o">.</span><span class="n">set_process_title</span><span class="p">(</span><span class="s">&quot;celerybeat&quot;</span><span class="p">)</span>
+
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_shutdown</span><span class="o">.</span><span class="n">isSet</span><span class="p">():</span>
+                <span class="n">interval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">tick</span><span class="p">()</span>
+                <span class="bp">self</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Celerybeat: Waking up </span><span class="si">%s</span><span class="s">.&quot;</span> <span class="o">%</span> <span class="p">(</span>
+                        <span class="n">humanize_seconds</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s">&quot;in &quot;</span><span class="p">)))</span>
+                <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span>
+        <span class="k">except</span> <span class="p">(</span><span class="ne">KeyboardInterrupt</span><span class="p">,</span> <span class="ne">SystemExit</span><span class="p">):</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">_is_shutdown</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
+        <span class="k">finally</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">sync</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">sync</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">scheduler</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_is_stopped</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Celerybeat: Shutting down...&quot;</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">_is_shutdown</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
+        <span class="n">wait</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_stopped</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>  <span class="c"># block until shutdown done.</span>
+
+    <span class="k">def</span> <span class="nf">get_scheduler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
+        <span class="n">filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schedule_filename</span>
+        <span class="n">scheduler</span> <span class="o">=</span> <span class="n">instantiate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scheduler_cls</span><span class="p">,</span>
+                                <span class="n">app</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="p">,</span>
+                                <span class="n">schedule_filename</span><span class="o">=</span><span class="n">filename</span><span class="p">,</span>
+                                <span class="n">logger</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="p">,</span>
+                                <span class="n">max_interval</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">max_interval</span><span class="p">,</span>
+                                <span class="n">lazy</span><span class="o">=</span><span class="n">lazy</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">scheduler</span>
+
+    <span class="nd">@cached_property</span>
+    <span class="k">def</span> <span class="nf">scheduler</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_scheduler</span><span class="p">()</span>
+
+
+<span class="k">class</span> <span class="nc">_Threaded</span><span class="p">(</span><span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Embedded task scheduler using threading.&quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="nb">super</span><span class="p">(</span><span class="n">_Threaded</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">()</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">setDaemon</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">setName</span><span class="p">(</span><span class="s">&quot;Beat&quot;</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">stop</span><span class="p">(</span><span class="n">wait</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+
+
+<span class="k">if</span> <span class="n">multiprocessing</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
+
+    <span class="k">class</span> <span class="nc">_Process</span><span class="p">(</span><span class="n">multiprocessing</span><span class="o">.</span><span class="n">Process</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;Embedded task scheduler using multiprocessing.&quot;&quot;&quot;</span>
+
+        <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+            <span class="nb">super</span><span class="p">(</span><span class="n">_Process</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">()</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;Beat&quot;</span>
+
+        <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+            <span class="n">platforms</span><span class="o">.</span><span class="n">signals</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s">&quot;SIGTERM&quot;</span><span class="p">)</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">start</span><span class="p">(</span><span class="n">embedded_process</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+
+        <span class="k">def</span> <span class="nf">stop</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
+<span class="k">else</span><span class="p">:</span>
+    <span class="n">_Process</span> <span class="o">=</span> <span class="bp">None</span>
+
+
+<div class="viewcode-block" id="EmbeddedService"><a class="viewcode-back" href="../../celery.html#celery.beat.EmbeddedService">[docs]</a><span class="k">def</span> <span class="nf">EmbeddedService</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Return embedded clock service.</span>
+
+<span class="sd">    :keyword thread: Run threaded instead of as a separate process.</span>
+<span class="sd">        Default is :const:`False`.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s">&quot;thread&quot;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span> <span class="ow">or</span> <span class="n">_Process</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+        <span class="c"># Need short max interval to be able to stop thread</span>
+        <span class="c"># in reasonable time.</span>
+        <span class="n">kwargs</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s">&quot;max_interval&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
+        <span class="k">return</span> <span class="n">_Threaded</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+    <span class="k">return</span> <span class="n">_Process</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>
+</pre></div>
+
+          </div>
+        </div>
+      </div>
+      <div class="sphinxsidebar">
+        <div class="sphinxsidebarwrapper">
+<div id="searchbox" style="display: none">
+  <h3>Quick search</h3>
+    <form class="search" action="../../search.html" method="get">
+      <input type="text" name="q" />
+      <input type="submit" value="Go" />
+      <input type="hidden" name="check_keywords" value="yes" />
+      <input type="hidden" name="area" value="default" />
+    </form>
+    <p class="searchtip" style="font-size: 90%">
+    Enter search terms or a module, class or function name.
+    </p>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+        </div>
+      </div>
+      <div class="clearer"></div>
+    </div>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             >index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" >Module code</a> &raquo;</li> 
+      </ul>
+    </div>
+    <div class="footer">
+        &copy; Copyright 2012, Yohann Gabory.
+      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
+    </div>
+  </body>
+</html>

documentation/build/_modules/celery/datastructures.html

+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>celery.datastructures &mdash; EggDiscover 0.1 documentation</title>
+    
+    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
+    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '../../',
+        VERSION:     '0.1',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="../../_static/jquery.js"></script>
+    <script type="text/javascript" src="../../_static/underscore.js"></script>
+    <script type="text/javascript" src="../../_static/doctools.js"></script>
+    <link rel="top" title="EggDiscover 0.1 documentation" href="../../index.html" />
+    <link rel="up" title="Module code" href="../index.html" /> 
+  </head>
+  <body>
+    <div class="related">
+      <h3>Navigation</h3>
+      <ul>
+        <li class="right" style="margin-right: 10px">
+          <a href="../../genindex.html" title="General Index"
+             accesskey="I">index</a></li>
+        <li class="right" >
+          <a href="../../py-modindex.html" title="Python Module Index"
+             >modules</a> |</li>
+        <li><a href="../../index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
+          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
+      </ul>
+    </div>  
+
+    <div class="document">
+      <div class="documentwrapper">
+        <div class="bodywrapper">
+          <div class="body">
+            
+  <h1>Source code for celery.datastructures</h1><div class="highlight"><pre>
+<span class="c"># -*- coding: utf-8 -*-</span>
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="sd">    celery.datastructures</span>
+<span class="sd">    ~~~~~~~~~~~~~~~~~~~~~</span>
+
+<span class="sd">    Custom types and data structures.</span>
+
+<span class="sd">    :copyright: (c) 2009 - 2011 by Ask Solem.</span>
+<span class="sd">    :license: BSD, see LICENSE for more details.</span>
+
+<span class="sd">&quot;&quot;&quot;</span>
+<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span>
+<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">with_statement</span>
+
+<span class="kn">import</span> <span class="nn">sys</span>
+<span class="kn">import</span> <span class="nn">time</span>
+<span class="kn">import</span> <span class="nn">traceback</span>
+
+<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">chain</span>
+<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">RLock</span>
+
+<span class="kn">from</span> <span class="nn">.utils.compat</span> <span class="kn">import</span> <span class="n">UserDict</span><span class="p">,</span> <span class="n">OrderedDict</span>
+
+
+<div class="viewcode-block" id="AttributeDictMixin"><a class="viewcode-back" href="../../celery.html#celery.datastructures.AttributeDictMixin">[docs]</a><span class="k">class</span> <span class="nc">AttributeDictMixin</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Adds attribute access to mappings.</span>
+
+<span class="sd">    `d.key -&gt; d[key]`</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="nf">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;`d.key -&gt; d[key]`&quot;&quot;&quot;</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="s">&quot;&#39;</span><span class="si">%s</span><span class="s">&#39; object has no attribute &#39;</span><span class="si">%s</span><span class="s">&#39;&quot;</span> <span class="o">%</span> <span class="p">(</span>
+                    <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="n">key</span><span class="p">))</span>
+
+    <span class="k">def</span> <span class="nf">__setattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
+        <span class="sd">&quot;&quot;&quot;`d[key] = value -&gt; d.key = value`&quot;&quot;&quot;</span>
+        <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
+
+</div>
+<div class="viewcode-block" id="AttributeDict"><a class="viewcode-back" href="../../celery.html#celery.datastructures.AttributeDict">[docs]</a><span class="k">class</span> <span class="nc">AttributeDict</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">AttributeDictMixin</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Dict subclass with attribute access.&quot;&quot;&quot;</span>
+    <span class="k">pass</span>
+
+</div>
+<div class="viewcode-block" id="DictAttribute"><a class="viewcode-back" href="../../celery.html#celery.datastructures.DictAttribute">[docs]</a><span class="k">class</span> <span class="nc">DictAttribute</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Dict interface to attributes.</span>
+
+<span class="sd">    `obj[k] -&gt; obj.k`</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">obj</span> <span class="o">=</span> <span class="n">obj</span>
+
+    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">default</span>
+
+    <span class="k">def</span> <span class="nf">setdefault</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">default</span>
+            <span class="k">return</span> <span class="n">default</span>
+
+    <span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
+        <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
+            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
+        <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__contains__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">_iterate_items</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</span><span class="p">)</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()</span>
+    <span class="n">iteritems</span> <span class="o">=</span> <span class="n">_iterate_items</span>
+
+    <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span>
+        <span class="n">items</span> <span class="o">=</span> <span class="n">_iterate_items</span>
+    <span class="k">else</span><span class="p">:</span>
+
+        <span class="k">def</span> <span class="nf">items</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iterate_items</span><span class="p">())</span>
+
+</div>
+<div class="viewcode-block" id="ConfigurationView"><a class="viewcode-back" href="../../celery.html#celery.datastructures.ConfigurationView">[docs]</a><span class="k">class</span> <span class="nc">ConfigurationView</span><span class="p">(</span><span class="n">AttributeDictMixin</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;A view over an applications configuration dicts.</span>
+
+<span class="sd">    If the key does not exist in ``changes``, the ``defaults`` dict</span>
+<span class="sd">    is consulted.</span>
+
+<span class="sd">    :param changes:  Dict containing changes to the configuration.</span>
+<span class="sd">    :param defaults: Dict containing the default configuration.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+    <span class="n">changes</span> <span class="o">=</span> <span class="bp">None</span>
+    <span class="n">defaults</span> <span class="o">=</span> <span class="bp">None</span>
+    <span class="n">_order</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">changes</span><span class="p">,</span> <span class="n">defaults</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">__dict__</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">changes</span><span class="o">=</span><span class="n">changes</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="n">defaults</span><span class="p">,</span>
+                             <span class="n">_order</span><span class="o">=</span><span class="p">[</span><span class="n">changes</span><span class="p">]</span> <span class="o">+</span> <span class="n">defaults</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+        <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_order</span><span class="p">:</span>
+            <span class="k">try</span><span class="p">:</span>
+                <span class="k">return</span> <span class="n">d</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+            <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+                <span class="k">pass</span>
+        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__setitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">changes</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
+
+    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="k">return</span> <span class="n">default</span>
+
+    <span class="k">def</span> <span class="nf">setdefault</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="p">):</span>
+        <span class="k">try</span><span class="p">:</span>
+            <span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
+        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
+            <span class="bp">self</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">default</span>
+            <span class="k">return</span> <span class="n">default</span>
+
+    <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">changes</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
+
+    <span class="k">def</span> <span class="nf">__contains__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
+        <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_order</span><span class="p">:</span>
+            <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">d</span><span class="p">:</span>
+                <span class="k">return</span> <span class="bp">True</span>
+        <span class="k">return</span> <span class="bp">False</span>
+
+    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">iteritems</span><span class="p">()))</span>
+
+    <span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">iterkeys</span><span class="p">()</span>
+
+    <span class="k">def</span> <span class="nf">_iter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">):</span>
+        <span class="c"># defaults must be first in the stream, so values in</span>
+        <span class="c"># changes takes precedence.</span>
+        <span class="k">return</span> <span class="n">chain</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">op</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_order</span><span class="p">)])</span>
+
+    <span class="k">def</span> <span class="nf">_iterate_keys</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_iter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">d</span><span class="p">:</span> <span class="n">d</span><span class="o">.</span><span class="n">iterkeys</span><span class="p">())</span>
+    <span class="n">iterkeys</span> <span class="o">=</span> <span class="n">_iterate_keys</span>
+
+    <span class="k">def</span> <span class="nf">_iterate_items</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_iter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">d</span><span class="p">:</span> <span class="n">d</span><span class="o">.</span><span class="n">iteritems</span><span class="p">())</span>
+    <span class="n">iteritems</span> <span class="o">=</span> <span class="n">_iterate_items</span>
+
+    <span class="k">def</span> <span class="nf">_iterate_values</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_iter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">d</span><span class="p">:</span> <span class="n">d</span><span class="o">.</span><span class="n">itervalues</span><span class="p">())</span>
+    <span class="n">itervalues</span> <span class="o">=</span> <span class="n">_iterate_values</span>
+
+    <span class="k">def</span> <span class="nf">keys</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iterate_keys</span><span class="p">())</span>
+
+    <span class="k">def</span> <span class="nf">items</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iterate_items</span><span class="p">())</span>
+
+    <span class="k">def</span> <span class="nf">values</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+        <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iterate_values</span><span class="p">())</span>
+
+</div>
+<span class="k">class</span> <span class="nc">_Code</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">code</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">co_filename</span> <span class="o">=</span> <span class="n">code</span><span class="o">.</span><span class="n">co_filename</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">co_name</span> <span class="o">=</span> <span class="n">code</span><span class="o">.</span><span class="n">co_name</span>
+
+
+<span class="k">class</span> <span class="nc">_Frame</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="n">Code</span> <span class="o">=</span> <span class="n">_Code</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">f_globals</span> <span class="o">=</span> <span class="p">{</span>
+            <span class="s">&quot;__file__&quot;</span><span class="p">:</span> <span class="n">frame</span><span class="o">.</span><span class="n">f_globals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&quot;__file__&quot;</span><span class="p">,</span> <span class="s">&quot;__main__&quot;</span><span class="p">),</span>
+        <span class="p">}</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">f_code</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Code</span><span class="p">(</span><span class="n">frame</span><span class="o">.</span><span class="n">f_code</span><span class="p">)</span>
+
+
+<span class="k">class</span> <span class="nc">Traceback</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="n">Frame</span> <span class="o">=</span> <span class="n">_Frame</span>
+
+    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tb</span><span class="p">):</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">tb_frame</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Frame</span><span class="p">(</span><span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="p">)</span>
+        <span class="bp">self</span><span class="o">.</span><span class="n">tb_lineno</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_lineno</span>
+        <span class="k">if</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">tb_next</span> <span class="o">=</span> <span class="bp">None</span>
+        <span class="k">else</span><span class="p">:</span>
+            <span class="bp">self</span><span class="o">.</span><span class="n">tb_next</span> <span class="o">=</span> <span class="n">Traceback</span><span class="p">(</span><span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span><span class="p">)</span>
+
+
+<div class="viewcode-block" id="ExceptionInfo"><a class="viewcode-back" href="../../celery.html#celery.datastructures.ExceptionInfo">[docs]</a><span class="k">class</span> <span class="nc">ExceptionInfo</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+    <span class="sd">&quot;&quot;&quot;Exception wrapping an exception and its traceback.</span>
+
+<span class="sd">    :param exc_info: The exception info tuple as returned by</span>
+<span class="sd">        :func:`sys.exc_info`.</span>
+
+<span class="sd">    &quot;&quot;&quot;</span>
+
+    <span class="c">#: Exception type.</span>
+    <span class="nb">type</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Exception instance.</span>
+    <span class="n">exception</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: Pickleable traceback instance for use with :mod:`traceback`</span>
+    <span class="n">tb</span> <span class="o">=</span> <span class="bp">None</span>
+
+    <span class="c">#: String representation of the traceback.</span>
+    <span class="n">traceback</span> <span class="o">=</span> <span class="bp">None</span>
+