Browse Source

Removes rarely used Tokyo Tyrant backend

Ask Solem 13 years ago
parent
commit
baeb485bdb

+ 0 - 1
celery/backends/__init__.py

@@ -19,7 +19,6 @@ BACKEND_ALIASES = {
     "cache": "celery.backends.cache:CacheBackend",
     "redis": "celery.backends.redis:RedisBackend",
     "mongodb": "celery.backends.mongodb:MongoBackend",
-    "tyrant": "celery.backends.tyrant:TyrantBackend",
     "database": "celery.backends.database:DatabaseBackend",
     "cassandra": "celery.backends.cassandra:CassandraBackend",
     "disabled": "celery.backends.base:DisabledBackend",

+ 0 - 94
celery/backends/tyrant.py

@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-"""celery.backends.tyrant"""
-from __future__ import absolute_import
-
-try:
-    import pytyrant
-except ImportError:
-    pytyrant = None  # noqa
-
-from celery.exceptions import ImproperlyConfigured
-
-from .base import KeyValueStoreBackend
-
-
-class TyrantBackend(KeyValueStoreBackend):
-    """Tokyo Cabinet based task backend store.
-
-    .. attribute:: tyrant_host
-
-        The hostname to the Tokyo Tyrant server.
-
-    .. attribute:: tyrant_port
-
-        The port to the Tokyo Tyrant server.
-
-    """
-    tyrant_host = None
-    tyrant_port = None
-
-    def __init__(self, tyrant_host=None, tyrant_port=None, **kwargs):
-        """Initialize Tokyo Tyrant backend instance.
-
-        Raises :class:`celery.exceptions.ImproperlyConfigured` if
-        :setting:`TT_HOST` or :setting:`TT_PORT` is not set.
-
-        """
-        super(TyrantBackend, self).__init__(**kwargs)
-
-        if not pytyrant:
-            raise ImproperlyConfigured(
-                    "You need to install the pytyrant library to use the "
-                  + "Tokyo Tyrant backend.")
-        self.tyrant_host = (tyrant_host or
-                            self.app.conf.get("TT_HOST") or
-                            self.tyrant_host)
-        self.tyrant_port = (tyrant_port or
-                            self.app.conf.get("TT_PORT") or
-                            self.tyrant_port)
-        if self.tyrant_port:
-            self.tyrant_port = int(self.tyrant_port)
-        if not self.tyrant_host or not self.tyrant_port:
-            raise ImproperlyConfigured(
-                "To use the Tokyo Tyrant backend, you have to "
-                "set the TT_HOST and TT_PORT settings in your settings.py")
-        self._connection = None
-
-    def open(self):
-        """Get :class:`pytyrant.PyTyrant` instance with the current
-        server configuration.
-
-        The connection is then cached until you do an
-        explicit :meth:`close`.
-
-        """
-        # connection overrides bool()
-        if self._connection is None:
-            self._connection = pytyrant.PyTyrant.open(self.tyrant_host,
-                                                      self.tyrant_port)
-        return self._connection
-
-    def close(self):
-        """Close the tyrant connection and remove the cache."""
-        # connection overrides bool()
-        if self._connection is not None:
-            self._connection.close()
-            self._connection = None
-
-    def process_cleanup(self):
-        self.close()
-
-    def get(self, key):
-        return self.open().get(key)
-
-    def set(self, key, value):
-        self.open()[key] = value
-
-    def delete(self, key):
-        self.open().pop(key, None)
-
-    def __reduce__(self, args=(), kwargs={}):
-        kwargs.update(
-            dict(tyrant_host=self.tyrant_host,
-                 tyrant_port=self.tyrant_port))
-        return super(TyrantBackend, self).__reduce__(args, kwargs)

+ 0 - 105
celery/tests/test_backends/test_tyrant.py

@@ -1,105 +0,0 @@
-from __future__ import absolute_import
-
-import sys
-import socket
-
-from nose import SkipTest
-
-from celery.exceptions import ImproperlyConfigured
-
-from celery import states
-from celery.utils import uuid
-from celery.backends import tyrant
-from celery.backends.tyrant import TyrantBackend
-from celery.tests.utils import Case
-
-_no_tyrant_msg = "* Tokyo Tyrant %s. Will not execute related tests."
-_no_tyrant_msg_emitted = False
-
-
-class SomeClass(object):
-
-    def __init__(self, data):
-        self.data = data
-
-
-def get_tyrant_or_SkipTest():
-
-    def emit_no_tyrant_msg(reason):
-        global _no_tyrant_msg_emitted
-        if not _no_tyrant_msg_emitted:
-            sys.stderr.write("\n" + _no_tyrant_msg % reason + "\n")
-            _no_tyrant_msg_emitted = True
-
-    if tyrant.pytyrant is None:
-        emit_no_tyrant_msg("not installed")
-        raise SkipTest("pytyrant library not installed")
-
-    try:
-        tb = TyrantBackend()
-        try:
-            tb.open()
-        except socket.error, exc:
-            emit_no_tyrant_msg("not running")
-            raise SkipTest("Can't connect to Tokyo server: %s" % (exc, ))
-        return tb
-    except ImproperlyConfigured, exc:
-        if "need to install" in str(exc):
-            emit_no_tyrant_msg("not installed")
-            raise SkipTest("Tokyo Tyrant is not installed")
-        emit_no_tyrant_msg("not configured")
-        raise SkipTest("Tokyo Tyrant not configured")
-
-
-class TestTyrantBackend(Case):
-
-    def test_cached_connection(self):
-        tb = get_tyrant_or_SkipTest()
-
-        self.assertIsNotNone(tb._connection)
-        tb.close()
-        self.assertIsNone(tb._connection)
-        tb.open()
-        self.assertIsNone(tb._connection)
-
-    def test_mark_as_done(self):
-        tb = get_tyrant_or_SkipTest()
-
-        tid = uuid()
-
-        self.assertEqual(tb.get_status(tid), states.PENDING)
-        self.assertIsNone(tb.get_result(tid), None)
-
-        tb.mark_as_done(tid, 42)
-        self.assertEqual(tb.get_status(tid), states.SUCCESS)
-        self.assertEqual(tb.get_result(tid), 42)
-
-    def test_is_pickled(self):
-        tb = get_tyrant_or_SkipTest()
-
-        tid2 = uuid()
-        result = {"foo": "baz", "bar": SomeClass(12345)}
-        tb.mark_as_done(tid2, result)
-        # is serialized properly.
-        rindb = tb.get_result(tid2)
-        self.assertEqual(rindb.get("foo"), "baz")
-        self.assertEqual(rindb.get("bar").data, 12345)
-
-    def test_mark_as_failure(self):
-        tb = get_tyrant_or_SkipTest()
-
-        tid3 = uuid()
-        try:
-            raise KeyError("foo")
-        except KeyError, exception:
-            pass
-        tb.mark_as_failure(tid3, exception)
-        self.assertEqual(tb.get_status(tid3), states.FAILURE)
-        self.assertIsInstance(tb.get_result(tid3), KeyError)
-
-    def test_process_cleanup(self):
-        tb = get_tyrant_or_SkipTest()
-
-        tb.process_cleanup()
-
-        self.assertIsNone(tb._connection)

+ 0 - 1
contrib/release/py3k-run-tests

@@ -28,7 +28,6 @@ nosetests -vd celery.tests                                      \
               celery.concurrency.threads                        \
               celery.concurrency.gevent                         \
               celery.backends.mongodb                           \
-              celery.backends.tyrant                            \
               celery.backends.cassandra                         \
               celery.events.dumper                              \
               celery.events.cursesmon"                          \

+ 0 - 41
docs/configuration.rst

@@ -191,10 +191,6 @@ Can be one of the following:
     Use `Redis`_ to store the results.
     See :ref:`conf-redis-result-backend`.
 
-* tyrant
-    Use `Tokyo Tyrant`_ to store the results.
-    See :ref:`conf-tyrant-result-backend`.
-
 * amqp
     Send results back as AMQP messages
     See :ref:`conf-amqp-result-backend`.
@@ -212,7 +208,6 @@ Can be one of the following:
 .. _`memcached`: http://memcached.org
 .. _`MongoDB`: http://mongodb.org
 .. _`Redis`: http://code.google.com/p/redis/
-.. _`Tokyo Tyrant`: http://1978th.net/tokyotyrant/
 .. _`Cassandra`: http://cassandra.apache.org/
 
 .. setting:: CELERY_RESULT_SERIALIZER
@@ -384,42 +379,6 @@ setting:
 
 .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
 
-.. _conf-tyrant-result-backend:
-
-Tokyo Tyrant backend settings
------------------------------
-
-.. note::
-
-    The Tokyo Tyrant backend requires the :mod:`pytyrant` library:
-    http://pypi.python.org/pypi/pytyrant/
-
-This backend requires the following configuration directives to be set:
-
-.. setting:: TT_HOST
-
-TT_HOST
-~~~~~~~
-
-Host name of the Tokyo Tyrant server.
-
-.. setting:: TT_PORT
-
-TT_PORT
-~~~~~~~
-
-The port the Tokyo Tyrant server is listening to.
-
-
-Example configuration
-~~~~~~~~~~~~~~~~~~~~~
-
-.. code-block:: python
-
-    CELERY_RESULT_BACKEND = "tyrant"
-    TT_HOST = "localhost"
-    TT_PORT = 1978
-
 .. _conf-redis-result-backend:
 
 Redis backend settings

+ 0 - 11
docs/internals/reference/celery.backends.tyrant.rst

@@ -1,11 +0,0 @@
-===============================================
- celery.backends.tyrant
-===============================================
-
-.. contents::
-    :local:
-.. currentmodule:: celery.backends.tyrant
-
-.. automodule:: celery.backends.tyrant
-    :members:
-    :undoc-members:

+ 0 - 1
docs/internals/reference/index.rst

@@ -35,7 +35,6 @@
     celery.backends.mongodb
     celery.backends.redis
     celery.backends.cassandra
-    celery.backends.tyrant
     celery.task.trace
     celery.app.abstract
     celery.app.annotations

+ 0 - 1
funtests/setup.py

@@ -52,7 +52,6 @@ setup(
         "unittest2>=0.4.0",
         "simplejson",
         "nose",
-        "pytyrant",
         "redis",
         "pymongo",
     ],

+ 0 - 1
setup.cfg

@@ -26,7 +26,6 @@ cover3-exclude = celery
                  celery.concurrency.threads
                  celery.concurrency.gevent
                  celery.backends.mongodb
-                 celery.backends.tyrant
                  celery.backends.cassandra
                  celery.events.dumper
                  celery.events.cursesmon