Permalink
Browse files

Module celery.state renamed -> celery._state

  • Loading branch information...
1 parent 6088d5f commit c16c0fed24b678930f1e56b37d53b238c69685d9 @ask ask committed Jun 22, 2012
View
9 MANIFEST.in
@@ -12,11 +12,4 @@ recursive-include docs *
recursive-include extra *
recursive-include examples *
recursive-include requirements *.txt
-prune tests/*.pyc
-prune docs/*.pyc
-prune extra/*.pyc
-prune celery/*.pyc
-prune examples/*.pyc
-prune bin/*.pyc
-prune docs/.build
-prune .tox/*
+prune *.pyc
View
2 celery/__init__.py
@@ -23,7 +23,7 @@
by_module={
'celery.app': ['Celery', 'bugreport'],
'celery.app.task': ['Task'],
- 'celery.state': ['current_app', 'current_task'],
+ 'celery._state': ['current_app', 'current_task'],
'celery.canvas': ['chain', 'chord', 'chunks',
'group', 'subtask', 'xmap', 'xstarmap'],
'celery.utils': ['uuid'],
View
7 celery/state.py → celery/_state.py
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
"""
- celery.state
+ celery._state
~~~~~~~~~~~~~~~
This is an internal module containing thread state
- like the current_app, and current_task. But these
- should not be imported from here.
+ like the ``current_app``, and ``current_task``.
+
+ This module shouldn't be used directly.
"""
from __future__ import absolute_import
View
14 celery/app/__init__.py
@@ -11,8 +11,8 @@
import os
from celery.local import Proxy
-from celery import state
-from celery.state import ( # noqa
+from celery import _state
+from celery._state import ( # noqa
set_default_app,
get_current_app as current_app,
get_current_task as current_task,
@@ -21,7 +21,7 @@
from .base import Celery, AppPickler # noqa
#: Proxy always returning the app set as default.
-default_app = Proxy(lambda: state.default_app)
+default_app = Proxy(lambda: _state.default_app)
#: Function returning the app provided or the default app if none.
#:
@@ -45,23 +45,23 @@ def bugreport():
def _app_or_default(app=None):
if app is None:
- return state.get_current_app()
+ return _state.get_current_app()
return app
def _app_or_default_trace(app=None): # pragma: no cover
from traceback import print_stack
from billiard import current_process
if app is None:
- if getattr(state._tls, 'current_app', None):
+ if getattr(_state._tls, 'current_app', None):
print('-- RETURNING TO CURRENT APP --') # noqa+
print_stack()
- return state._tls.current_app
+ return _state._tls.current_app
if current_process()._name == 'MainProcess':
raise Exception('DEFAULT APP')
print('-- RETURNING TO DEFAULT APP --') # noqa+
print_stack()
- return state.default_app
+ return _state.default_app
return app
View
2 celery/app/base.py
@@ -24,7 +24,7 @@
from celery.exceptions import AlwaysEagerIgnored
from celery.loaders import get_loader_cls
from celery.local import PromiseProxy, maybe_evaluate
-from celery.state import _task_stack, _tls, get_current_app
+from celery._state import _task_stack, _tls, get_current_app
from celery.utils.functional import first
from celery.utils.imports import instantiate, symbol_by_name
View
2 celery/app/builtins.py
@@ -12,7 +12,7 @@
from itertools import starmap
-from celery.state import get_current_worker_task
+from celery._state import get_current_worker_task
from celery.utils import uuid
#: global list of functions defining tasks that should be
View
2 celery/app/log.py
@@ -19,7 +19,7 @@
from kombu.log import NullHandler
from celery import signals
-from celery.state import get_current_task
+from celery._state import get_current_task
from celery.utils import isatty
from celery.utils.compat import WatchedFileHandler
from celery.utils.log import (
View
2 celery/app/task.py
@@ -17,7 +17,7 @@
from celery import current_app
from celery import states
from celery.__compat__ import class_property
-from celery.state import get_current_worker_task, _task_stack
+from celery._state import get_current_worker_task, _task_stack
from celery.datastructures import ExceptionInfo
from celery.exceptions import MaxRetriesExceededError, RetryTaskError
from celery.result import EagerResult
View
2 celery/backends/__init__.py
@@ -13,7 +13,7 @@
from kombu.utils.url import _parse_url
from celery.local import Proxy
-from celery.state import current_app
+from celery._state import current_app
from celery.utils.imports import symbol_by_name
from celery.utils.functional import memoize
View
2 celery/concurrency/processes/__init__.py
@@ -17,7 +17,7 @@
from celery import platforms
from celery import signals
-from celery.state import set_default_app
+from celery._state import set_default_app
from celery.concurrency.base import BasePool
from celery.task import trace
from billiard.pool import Pool, RUN, CLOSE
View
2 celery/loaders/__init__.py
@@ -9,7 +9,7 @@
"""
from __future__ import absolute_import
-from celery.state import current_app
+from celery._state import current_app
from celery.utils import deprecated
from celery.utils.imports import symbol_by_name
View
2 celery/task/__init__.py
@@ -8,7 +8,7 @@
"""
from __future__ import absolute_import
-from celery.state import current_app, current_task as current
+from celery._state import current_app, current_task as current
from celery.__compat__ import MagicModule, recreate_module
from celery.local import Proxy
View
2 celery/task/sets.py
@@ -10,7 +10,7 @@
from __future__ import absolute_import
from __future__ import with_statement
-from celery.state import get_current_worker_task
+from celery._state import get_current_worker_task
from celery.app import app_or_default
from celery.canvas import subtask, maybe_subtask # noqa
from celery.utils import uuid
View
2 celery/task/trace.py
@@ -25,7 +25,7 @@
from celery import current_app
from celery import states, signals
-from celery.state import _task_stack, default_app
+from celery._state import _task_stack, default_app
from celery.app.task import Task as BaseTask, Context
from celery.datastructures import ExceptionInfo
from celery.exceptions import RetryTaskError
View
18 celery/tests/app/test_app.py
@@ -10,7 +10,7 @@
from celery import Celery
from celery import app as _app
-from celery import state
+from celery import _state
from celery.app import defaults
from celery.loaders.base import BaseLoader
from celery.platforms import pyimplementation
@@ -43,7 +43,7 @@ def _get_test_config():
class test_module(Case):
def test_default_app(self):
- self.assertEqual(_app.default_app, state.default_app)
+ self.assertEqual(_app.default_app, _state.default_app)
def test_bugreport(self):
self.assertTrue(_app.bugreport())
@@ -87,12 +87,12 @@ def test_include_argument(self):
self.assertEqual(app.conf.CELERY_IMPORTS, ('foo', 'bar.foo'))
def test_set_as_current(self):
- current = state._tls.current_app
+ current = _state._tls.current_app
try:
app = Celery(set_as_current=True)
- self.assertIs(state._tls.current_app, app)
+ self.assertIs(_state._tls.current_app, app)
finally:
- state._tls.current_app = current
+ _state._tls.current_app = current
def test_current_task(self):
app = Celery(set_as_current=False)
@@ -101,11 +101,11 @@ def test_current_task(self):
def foo():
pass
- state._task_stack.push(foo)
+ _state._task_stack.push(foo)
try:
self.assertEqual(app.current_task.name, foo.name)
finally:
- state._task_stack.pop()
+ _state._task_stack.pop()
def test_task_not_shared(self):
with patch('celery.app.base.shared_task') as shared_task:
@@ -222,7 +222,7 @@ def aacaX():
aacaX.apply_async(connection=connection)
def test_apply_async_adds_children(self):
- from celery.state import _task_stack
+ from celery._state import _task_stack
app = Celery(set_as_current=False)
@app.task()
@@ -350,7 +350,7 @@ def test_AsyncResult(self):
self.assertIs(x.app, self.app)
r = loads(dumps(x))
# not set as current, so ends up as default app after reduce
- self.assertIs(r.app, state.default_app)
+ self.assertIs(r.app, _state.default_app)
@patch('celery.bin.celery.CeleryCommand.execute_from_commandline')
def test_start(self, execute):
View
2 celery/tests/app/test_builtins.py
@@ -4,7 +4,7 @@
from celery import current_app as app, group, task, chord
from celery.app import builtins
-from celery.state import _task_stack
+from celery._state import _task_stack
from celery.tests.utils import Case
View
4 celery/tests/app/test_log.py
@@ -245,11 +245,11 @@ def test_task():
pass
self.get_logger().handlers = []
self.task = test_task
- from celery.state import _task_stack
+ from celery._state import _task_stack
_task_stack.push(test_task)
def tearDown(self):
- from celery.state import _task_stack
+ from celery._state import _task_stack
_task_stack.pop()
def setup_logger(self, *args, **kwargs):
View
2 celery/tests/tasks/test_sets.py
@@ -148,7 +148,7 @@ def send(self, *args, **kwargs):
@current_app.task
def xyz():
pass
- from celery.state import _task_stack
+ from celery._state import _task_stack
_task_stack.push(xyz)
try:
ts.apply_async(publisher=Publisher())
View
2 celery/tests/worker/test_worker.py
@@ -775,7 +775,7 @@ def test_use_pidfile(self, create_pidlock):
def test_process_initializer(self, set_mp_process_title, _signals):
from celery import Celery
from celery import signals
- from celery.state import _tls
+ from celery._state import _tls
from celery.concurrency.processes import process_initializer
from celery.concurrency.processes import (WORKER_SIGRESET,
WORKER_SIGIGNORE)
View
6 docs/internals/reference/celery.state.rst → docs/internals/reference/celery._state.rst
@@ -1,11 +1,11 @@
========================================
- celery.state
+ celery._state
========================================
.. contents::
:local:
-.. currentmodule:: celery.state
+.. currentmodule:: celery._state
-.. automodule:: celery.state
+.. automodule:: celery._state
:members:
:undoc-members:
View
2 docs/internals/reference/index.rst
@@ -37,7 +37,6 @@
celery.backends.mongodb
celery.backends.redis
celery.backends.cassandra
- celery.state
celery.task.trace
celery.app.abstract
celery.app.annotations
@@ -67,3 +66,4 @@
celery.utils.dispatch.signal
celery.utils.dispatch.saferef
celery.platforms
+ celery._state

0 comments on commit c16c0fe

Please sign in to comment.