GithubHelp home page GithubHelp logo

celery / kombu Goto Github PK

View Code? Open in Web Editor NEW
2.8K 75.0 921.0 8.5 MB

Messaging library for Python.

Home Page: http://kombu.readthedocs.org/

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.30% Python 99.70%
celery messaging python message-queue kombu python-library python3 python-3 rabbitmq sqs

kombu's Introduction

kombu - Messaging library for Python

Build status coverage BSD License Kombu can be installed via wheel Supported Python versions. Support Python implementations. downloads

Version:5.4.0rc2
Documentation:https://kombu.readthedocs.io/
Download:https://pypi.org/project/kombu/
Source:https://github.com/celery/kombu/
Keywords:messaging, amqp, rabbitmq, redis, mongodb, python, queue

About

Kombu is a messaging library for Python.

The aim of Kombu is to make messaging in Python as easy as possible by providing an idiomatic high-level interface for the AMQ protocol, and also provide proven and tested solutions to common messaging problems.

AMQP is the Advanced Message Queuing Protocol, an open standard protocol for message orientation, queuing, routing, reliability and security, for which the RabbitMQ messaging server is the most popular implementation.

Features

  • Allows application authors to support several message server solutions by using pluggable transports.

  • Supports automatic encoding, serialization and compression of message payloads.

  • Consistent exception handling across transports.

  • The ability to ensure that an operation is performed by gracefully handling connection and channel errors.

  • Several annoyances with amqplib has been fixed, like supporting timeouts and the ability to wait for events on more than one channel.

  • Projects already using carrot can easily be ported by using a compatibility layer.

For an introduction to AMQP you should read the article Rabbits and warrens, and the Wikipedia article about AMQP.

Transport Comparison

Client Type Direct Topic Fanout Priority TTL
amqp Native Yes Yes Yes Yes [3] Yes [4]
qpid Native Yes Yes Yes No No
redis Virtual Yes Yes Yes (PUB/SUB) Yes No
mongodb Virtual Yes Yes Yes Yes Yes
SQS Virtual Yes Yes [1] Yes [2] No No
zookeeper Virtual Yes Yes [1] No Yes No
in-memory Virtual Yes Yes [1] No No No
SLMQ Virtual Yes Yes [1] No No No
Pyro Virtual Yes Yes [1] No No No
[1](1, 2, 3, 4, 5) Declarations only kept in memory, so exchanges/queues must be declared by all clients that needs them.
[2]Fanout supported via storing routing tables in SimpleDB. Disabled by default, but can be enabled by using the supports_fanout transport option.
[3]AMQP Message priority support depends on broker implementation.
[4]AMQP Message/Queue TTL support depends on broker implementation.

Documentation

Kombu is using Sphinx, and the latest documentation can be found here:

https://kombu.readthedocs.io/

Quick overview

from kombu import Connection, Exchange, Queue

media_exchange = Exchange('media', 'direct', durable=True)
video_queue = Queue('video', exchange=media_exchange, routing_key='video')

def process_media(body, message):
    print(body)
    message.ack()

# connections
with Connection('amqp://guest:guest@localhost//') as conn:

    # produce
    producer = conn.Producer(serializer='json')
    producer.publish({'name': '/tmp/lolcat1.avi', 'size': 1301013},
                      exchange=media_exchange, routing_key='video',
                      declare=[video_queue])

    # the declare above, makes sure the video queue is declared
    # so that the messages can be delivered.
    # It's a best practice in Kombu to have both publishers and
    # consumers declare the queue. You can also declare the
    # queue manually using:
    #     video_queue(conn).declare()

    # consume
    with conn.Consumer(video_queue, callbacks=[process_media]) as consumer:
        # Process messages and handle events on all channels
        while True:
            conn.drain_events()

# Consume from several queues on the same channel:
video_queue = Queue('video', exchange=media_exchange, key='video')
image_queue = Queue('image', exchange=media_exchange, key='image')

with connection.Consumer([video_queue, image_queue],
                         callbacks=[process_media]) as consumer:
    while True:
        connection.drain_events()

Or handle channels manually:

with connection.channel() as channel:
    producer = Producer(channel, ...)
    consumer = Consumer(channel)

All objects can be used outside of with statements too, just remember to close the objects after use:

from kombu import Connection, Consumer, Producer

connection = Connection()
    # ...
connection.release()

consumer = Consumer(channel_or_connection, ...)
consumer.register_callback(my_callback)
consumer.consume()
    # ....
consumer.cancel()

Exchange and Queue are simply declarations that can be pickled and used in configuration files etc.

They also support operations, but to do so they need to be bound to a channel.

Binding exchanges and queues to a connection will make it use that connections default channel.

>>> exchange = Exchange('tasks', 'direct')

>>> connection = Connection()
>>> bound_exchange = exchange(connection)
>>> bound_exchange.delete()

# the original exchange is not affected, and stays unbound.
>>> exchange.delete()
raise NotBoundError: Can't call delete on Exchange not bound to
    a channel.

Terminology

There are some concepts you should be familiar with before starting:

  • Producers

    Producers sends messages to an exchange.

  • Exchanges

    Messages are sent to exchanges. Exchanges are named and can be configured to use one of several routing algorithms. The exchange routes the messages to consumers by matching the routing key in the message with the routing key the consumer provides when binding to the exchange.

  • Consumers

    Consumers declares a queue, binds it to a exchange and receives messages from it.

  • Queues

    Queues receive messages sent to exchanges. The queues are declared by consumers.

  • Routing keys

    Every message has a routing key. The interpretation of the routing key depends on the exchange type. There are four default exchange types defined by the AMQP standard, and vendors can define custom types (so see your vendors manual for details).

    These are the default exchange types defined by AMQP/0.8:

    • Direct exchange

      Matches if the routing key property of the message and the routing_key attribute of the consumer are identical.

    • Fan-out exchange

      Always matches, even if the binding does not have a routing key.

    • Topic exchange

      Matches the routing key property of the message by a primitive pattern matching scheme. The message routing key then consists of words separated by dots (".", like domain names), and two special characters are available; star ("*") and hash ("#"). The star matches any word, and the hash matches zero or more words. For example "*.stock.#" matches the routing keys "usd.stock" and "eur.stock.db" but not "stock.nasdaq".

Installation

You can install Kombu either via the Python Package Index (PyPI) or from source.

To install using pip,:

$ pip install kombu

To install using easy_install,:

$ easy_install kombu

If you have downloaded a source tarball you can install it by doing the following,:

$ python setup.py build
# python setup.py install # as root

Getting Help

Mailing list

Join the `celery-users`_ mailing list.

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to our issue tracker at https://github.com/celery/kombu/issues/

Contributing

Development of Kombu happens at Github: https://github.com/celery/kombu

You are highly encouraged to participate in the development. If you don't like Github (for some reason) you're welcome to send regular patches.

License

This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the full license text.

kombu as part of the Tidelift Subscription

The maintainers of kombu and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/pypi-kombu?utm_source=pypi-kombu&utm_medium=referral&utm_campaign=readme&utm_term=repo)

--

kombu's People

Contributors

adamn avatar alukach avatar ask avatar atombrella avatar auvipy avatar beav avatar bmbouter avatar cclauss avatar daevaorn avatar dependabot[bot] avatar diranged avatar flaper87 avatar georgepsarakis avatar ionelmc avatar jasonwbarnett avatar jdufresne avatar kludex avatar last-g avatar matusvalo avatar mher avatar nazavode avatar nusnus avatar pawl avatar pre-commit-ci[bot] avatar priteau avatar pyup-bot avatar rumineykova avatar slyons avatar stegayet avatar thedrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kombu's Issues

Couchdb credentials aren't sent to server

When a new connection is created on CouchDB databases, userid and password are in conninfo variable at _opent method, but they aren't used. Thus if CouchDB needs authentication the connection will fail, raising UnauthorizedError.

Version sniffing for mongodb RC fails with ValueError

I have a release candidate version running and the whole map(int, version.split(".")) is a bit too optimistic (https://github.com/ask/kombu/blob/master/kombu/transport/mongodb.py#L61):

[2011-03-29 14:57:18,165: WARNING/MainProcess] File "/pyenv/lib/python2.6/site-packages/kombu/transport/mongodb.py", line 62, in _open
[2011-03-29 14:57:18,165: WARNING/MainProcess] if tuple(map(int, version.split("."))) < (1, 3):
[2011-03-29 14:57:18,165: WARNING/MainProcess] ValueError:
[2011-03-29 14:57:18,165: WARNING/MainProcess] invalid literal for int() with base 10: '0-rc0'

Since you only need to check for >1.3, checking the major and minor version number should be sufficient:

if tuple(map(int, version.split(".")[:2])) < (1, 3):

Error om ampqlib.client.serialization line 454

Hi,

I'm getting this error:
File "/var/www/django/midgardur/lib/python2.6/site-packages/amqplib/client_0_8/serialization.py", line 454, in getattr
raise AttributeError(name)
AttributeError: application_headers
called from (/kombu/transport/pyamqplib.py", line 148, in init)

any ideas?

regards,
-Stefan

No method for enabling SASL EXTERNAL authentication

We're trying to connect with the amqplib authentication options, but they doesn't appear to be properly supported by Kombu yet. It's essential for the "EXTERNAL" login_method get passed through to amqplib.

Pika backend raises socket.timeout("timed out")

Taken the suggested example at http://ask.github.com/kombu/introduction.html#quick-overview

when I change from amqplib to pika, I get a socket.timeout("timed out") after a few seconds

I don't see any way to avoid that, since the documentation is not clear about switching backends "properly" (imho: just telling the BrokerConnection about the transport='pika')...

since I tried kombu.transport.pypika.AsyncoreConnection.ensure_drain_events() without the following

if self._event_counter <= current_events:
    raise socket.timeout("timed out")

and it was working without problems, I am assuming some unwanted behavior there...

do I miss something?

thanks anyway
Oliver

AMQPChannelException (PRECONDITION_FAILED - unknown delivery tag 1) while handling messages

I use Kombu 1.0.3 as underlying library for my AMQP consumer framework.

Settings:
no_ack: True because I will message.ack() explicitly myself (in my test codes, every message will be acked explicitly)
prefetch_count: 1
durable: True
auto_ack: False
auto_declare: True

After receiving and handling several messages successfully (10 - 50), my consumer process exits because of the following exception:

2011-02-15 12:15:56,750: WARNING - consumer.amqp.sample.UploadPhoto.worker - 34728 - Traceback (most recent call last):
File "/Users/dinhpham/dev/workspace/server_api_core/trunk/src/skunkworks/lbs/task/amqp/consumer.py", line 171, in start
self.connection.drain_events()
File "/Library/Python/2.6/site-packages/kombu/connection.py", line 110, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/Library/Python/2.6/site-packages/kombu/transport/pyamqplib.py", line 200, in drain_events
return connection.drain_events(**kwargs)
File "/Library/Python/2.6/site-packages/kombu/transport/pyamqplib.py", line 50, in drain_events
return self.wait_multi(self.channels.values(), timeout=timeout)
File "/Library/Python/2.6/site-packages/kombu/transport/pyamqplib.py", line 75, in wait_multi
return amqp_method(channel, args)
File "/Library/Python/2.6/site-packages/amqplib/client_0_8/channel.py", line 273, in _close
(class_id, method_id))
AMQPChannelException: (406, u'PRECONDITION_FAILED - unknown delivery tag 1', (60, 80), 'Channel.basic_ack')

AttributeError _handle_message

File "/Users/herve/.local/nagare_python-2.6.4/lib/python2.6/site-packages/kombu-1.0.0rc4-py2.6.egg/kombu/transport/pyredis.py", line 171, in _receive
payload = c._handle_message(response)
AttributeError: 'Redis' object has no attribute '_handle_message'

I had to monkey patch redis-2.0.0 with the following:

def _handle_message(self, r):
    if r[0] == 'pmessage':
        msg = {
        'type': r[0],
        'pattern': r[1],
        'channel': r[2],
        'data': r[3]
        }
    else:
        msg = {
        'type': r[0],
        'pattern': None,
        'channel': r[1],
        'data': r[2]
        }
    return msg

But I think there is some version mismatch between kombu and redis installed in my virtualenv (everything was installed with easy_install).

Redis backend doesn't seem to handle nondefault queues

Using Celery master with the celeryconfig.py below, it doesn't seem like the consumer will pickup tasks from non-default queues.

For example:

$ celeryctl apply some_task
$ celeryd
... unknown task: some_task ...
$ celeryctl apply --queue=foo --exchange=foo some_task
$ celeryd --queue=foo
... doesn't pick up the task ...

At this point I haven't done much debugging, but I have verified that the Consumer gets the correct value for queues:

(Pdb) self.queues
{'foo': {'binding_key': 'foo', 'exchange_type': 'direct', 'routing_key': 'foo', 'exchange': 'foo'}}

And this is the content of the Redis DB:

redis> lrange ae.undeliver 0 1
1. "{\"body\": \"{\\\"retries\\\": 0, \\\"task\\\": \\\"asdf\\\", \\\"args\\\": [], \\\"expires\\\": null, \\\"eta\\\": null, \\\"kwargs\\\": {}, \\\"id\\\": \\\"3d540978-280a-4c0e-89de-70368fe6abd1\\\"}\", \"headers\": {}, \"content-type\": \"application/json\", \"properties\": {\"delivery_info\": {\"priority\": 0, \"routing_key\": \"celery\", \"exchange\": \"foo\"}, \"delivery_mode\": 2, \"delivery_tag\": 1}, \"content-encoding\": \"utf-8\"}"
redis> keys *
1. "_kombu.binding.celery"
2. "ae.undeliver"
redis> lrange ae.undeliver 0 1
1. "{\"body\": \"{\\\"retries\\\": 0, \\\"task\\\": \\\"asdf\\\", \\\"args\\\": [], \\\"expires\\\": null, \\\"eta\\\": null, \\\"kwargs\\\": {}, \\\"id\\\": \\\"3d540978-280a-4c0e-89de-70368fe6abd1\\\"}\", \"headers\": {}, \"content-type\": \"application/json\", \"properties\": {\"delivery_info\": {\"priority\": 0, \"routing_key\": \"celery\", \"exchange\": \"foo\"}, \"delivery_mode\": 2, \"delivery_tag\": 1}, \"content-encoding\": \"utf-8\"}"
redis> smembers _kombu.binding.celery
1. "celery\x06\x16\x06\x16celery"
redis> 

I'll be debugging more tomorrowโ€ฆ

celeryconfig.py:

BROKER_BACKEND = "kombu.transport.pyredis.Transport"
BROKER_HOST = "localhost"
BROKER_PORT = 6379
BROKER_VHOST = "0"
CELERY_RESULT_BACKEND = "redis"
REDIS_HOST = "localhost"
REDIS_PORT = 6379
REDIS_DB = "0"

MemoryError importing ctypes with kombu+mod_wsgi+SELinux

We encountered this issue on CentOS 6 when running a django application that uses kombu. We run inside mod_wsgi+apache.

The symptom is that a MemoryException error is thrown when the app renders a page. The backtrace points to 'import ctypes' in kombu/utils/init.py.

For the record, here is the story of what's going on here:

  • The ctypes module uses the libffi library
  • The libffi library tries to write to /tmp, which isn't allowed for the apache user in a default SELinux config (https://bugzilla.redhat.com/show_bug.cgi?id=582009). In this environment, importing ctypes always throws a MemoryError
  • The normal python uuid.py doesn't care, it imports ctypes inside a catch-all except:, which catches the MemoryError and drops it silently.
  • Kombu has it's own implementation of a uuid function to work around an old python bug, so does its own 'import ctypes'. But it does it inside a "except ImportError".

To fix this, kombu should handle the import of ctypes in the same way as the built in python library does. I don't like doing catch-all except: statements, but in this instance the sensible thing to do is emulate the builtin python behaviour as much as possible.

Latest pika not supported

I have pika 0.9.3 installed. If I set transport="pika" I get the following error :

Traceback (most recent call last):
File "dumper.py", line 18, in
connection.connect()
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 95, in connect
return self.connection
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 396, in connection
self._connection = self._establish_connection()
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 364, in _establish_connection
return self.transport.establish_connection()
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 408, in transport
self._transport = self.create_transport()
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 218, in create_transport
return self.get_transport_cls()(client=self)
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/connection.py", line 225, in get_transport_cls
transport_cls = get_transport_cls(transport_cls)
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/transport/init.py", line 125, in get_transport_cls
_transport_cache[transport] = _get_transport_cls(transport)
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/transport/init.py", line 107, in _get_transport_cls
import(transport_module_name)
File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.3-py2.6.egg/kombu/transport/pypika.py", line 13, in
from pika import asyncore_adapter
ImportError: cannot import name asyncore_adapter

Not receiving messages

Hi,

I have been trying to port our lightweight messenger to use Kombu instead of Carrot. I have observed a few things that I would like to get your feedback on:

  • Multiple Bindings (called Queue in the documentation) are needed to support multiple routing keys. Each binding seams to creates a channel on the RabbitMQ side instead of having multiple routing_keys assigned to the same channel. Is this correct?
  • I'm not receiving messages and it's far from clear to me what is failing. Can I possibly share the code with you to see if you see something obviously wrong with it.
  • Can you please tell me what the status is of the code. I can see that you have been quite active lately (we appreciate that) and I'm wondering if you would recommend it's use right now.

Very best regards,
-Stefan Baxter

UnpicklingError after encoding message bodies in base64

Somehow the 68ee9c5 commit broke my Celery + Django deployment.

After it, Celery logs show:

[2011-04-15 15:17:07,416: CRITICAL/MainProcess] Can't decode message body: UnpicklingError('bad pickle data',) (type:u'application/x-python-serialize' encoding:u'binary' raw:u'KGRwMQpTJ3JldHJpZXMnCnAyCkkwCnNTJ3Rhc2snCnAzClMnY29saWJyaS5hY2NvdW50LnRhc2tzLnByb2Nlc3Nfb3JkZXInCnA0CnNTJ2FyZ3MnCnA1CihWNmU4MzMzNWItM2FlMS00N2E3LWIyOTctOTQyNGM1NmQ3YjI0CnA2CihkcDcKUydwYXltZW50X2NvZGUnCnA4ClYwMApwOQpzUydjYXJkX3NlY3VyaXR5X2NvZGUnCnAxMApWCnNTJ2NhcmRfZXhwaXJhdGlvbl9tb250aCcKcDExClYxCnNTJ2NhcmRfZXhwaXJhdGlvbl95ZWFyJwpwMTIKVjIwMTEKcDEzCnNTJ2NhcmRfZnVsbF9udW1iZXInCnAxNApWCnN0cDE1CnNTJ2V4cGlyZXMnCnAxNgpOc1MnZXRhJwpwMTcKTnNTJ2t3YXJncycKcDE4CihkcDE5CnNTJ2lkJwpwMjAKUydjY2ZhZjUzMS1iMTBmLTQzZTMtYTEwNC0wZGQ3YzIxNGViNjQnCnAyMQpzLg=='')

Although if I b64decode the message and unpickle it in a Python shell, I'm able to restore a Python object just fine. So the problem is not on the data itself, but somewhere in the the stack the data is not getting decoded in the correct order it seems. I bet the message is getting to celery still b64encoded, and it shouldn't. Any idea?

function' object has no attribute '_close'

I started getting the following warning message from celery workers.

kombu 1.4.3
celery 2.3.3

Here's a traceback:

INFO/PoolWorker-1] after forker raised exception 'function' object has no attribute '_close'
WARNING/PoolWorker-1] Traceback (most recent call last):
WARNING/PoolWorker-1] File "/usr/lib/python2.6/multiprocessing/util.py", line 130, in _run_after_forkers
WARNING/PoolWorker-1] func(obj)
WARNING/PoolWorker-1] File "/usr/local/lib/python2.6/dist-packages/celery/app/base.py", line 351, in _after_fork
WARNING/PoolWorker-1] self._pool.force_close_all()
WARNING/PoolWorker-1] File "/usr/local/lib/python2.6/dist-packages/kombu/connection.py", line 704, in force_close_all
WARNING/PoolWorker-1] self.close_resource(res)
WARNING/PoolWorker-1] File "/usr/local/lib/python2.6/dist-packages/kombu/connection.py", line 762, in close_resource
WARNING/PoolWorker-1] resource._close()
WARNING/PoolWorker-1] AttributeError: 'function' object has no attribute '_close'
INFO/PoolWorker-1] child process calling self.run()

Don't know if it's related, but I started getting the following exception occasionally in celery logs as well:

[2011-11-04 14:23:00,024: WARNING/PoolWorker-67] Exception
[2011-11-04 14:23:00,024: WARNING/PoolWorker-67] socket
[2011-11-04 14:23:00,024: WARNING/PoolWorker-67] .
[2011-11-04 14:23:00,024: WARNING/PoolWorker-67] error
[2011-11-04 14:23:00,024: WARNING/PoolWorker-67] :
2011-11-04 14:23:00,025: WARNING/PoolWorker-67
[2011-11-04 14:23:00,025: WARNING/PoolWorker-67] in
[2011-11-04 14:23:00,025: WARNING/PoolWorker-67] <bound method TCPTransport.del of <amqplib.client_0_8.transport.TCPTransport object at 0xaa3522c>>
[2011-11-04 14:23:00,025: WARNING/PoolWorker-67] ignored

Anyone knows what's going on ?

Lauris

'Redis' object has no attribute 'connection'

Hi
I am using celery 2.2.6 and it automatically installs kombu 1.1.3
This time when I use redis for my messaging que with the following celery config:

REDIS_CONNECT_RETRY = True
BROKER_BACKEND = "redis"
BROKER_HOST = "localhost"  # Maps to redis host.
BROKER_PORT = 6379         # Maps to redis port.
BROKER_VHOST = "0"         # Maps to database number.
CELERY_RESULT_BACKEND = "redis"
REDIS_HOST = "localhost"
REDIS_PORT = 6379
REDIS_DB = 0

and this is the error that I get:

[2011-06-05 19:47:40,763: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/transport/pyredis.py", line 86, in _register_BRPOP
[2011-06-05 19:47:40,763: WARNING/MainProcess] if channel.client.connection._sock is None or \
[2011-06-05 19:47:40,763: WARNING/MainProcess] AttributeError
[2011-06-05 19:47:40,763: WARNING/MainProcess] :
[2011-06-05 19:47:40,763: WARNING/MainProcess] 'Redis' object has no attribute 'connection'

the complete log:

[2011-06-05 19:59:28,472: WARNING/MainProcess] -------------- [email protected] v2.2.6
---- **** -----
--- * ***  * -- [Configuration]
-- * - **** ---   . broker:      redis://guest@localhost:6379/
- ** ----------   . loader:      celery.loaders.default.Loader
- ** ----------   . logfile:     celeryd.log@INFO
- ** ----------   . concurrency: 4
- ** ----------   . events:      ON
- *** --- * ---   . beat:        ON
-- ******* ----
--- ***** ----- [Queues]
 --------------   . celery:      exchange:celery (direct) binding:celery
                  

[Tasks]
  . monkey.check_status
[2011-06-05 19:59:28,480: INFO/PoolWorker-2] child process calling self.run()
[2011-06-05 19:59:28,480: INFO/PoolWorker-2] child process calling self.run()
[2011-06-05 19:59:28,480: INFO/PoolWorker-3] child process calling self.run()
[2011-06-05 19:59:28,480: INFO/PoolWorker-3] child process calling self.run()
[2011-06-05 19:59:28,481: INFO/PoolWorker-4] child process calling self.run()
[2011-06-05 19:59:28,481: INFO/PoolWorker-4] child process calling self.run()
[2011-06-05 19:59:28,482: INFO/PoolWorker-5] child process calling self.run()
[2011-06-05 19:59:28,482: INFO/PoolWorker-5] child process calling self.run()
[2011-06-05 19:59:28,485: WARNING/MainProcess] [email protected] has started.
[2011-06-05 19:59:28,486: INFO/Beat] child process calling self.run()
[2011-06-05 19:59:28,486: INFO/Beat] child process calling self.run()
[2011-06-05 19:59:28,486: INFO/Beat] Celerybeat: Starting...
[2011-06-05 19:59:28,493: WARNING/MainProcess] Traceback (most recent call last):
[2011-06-05 19:59:28,493: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/bin/celeryd", line 8, in 
[2011-06-05 19:59:28,494: WARNING/MainProcess] load_entry_point('celery==2.2.6', 'console_scripts', 'celeryd')()
[2011-06-05 19:59:28,494: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/bin/celeryd.py", line 187, in main
[2011-06-05 19:59:28,494: WARNING/MainProcess] worker.execute_from_commandline()
[2011-06-05 19:59:28,494: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/bin/base.py", line 72, in execute_from_commandline
[2011-06-05 19:59:28,494: WARNING/MainProcess] return self.handle_argv(prog_name, argv[1:])
[2011-06-05 19:59:28,494: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/bin/base.py", line 100, in handle_argv
[2011-06-05 19:59:28,494: WARNING/MainProcess] return self.run(*args, **vars(options))
[2011-06-05 19:59:28,494: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/bin/celeryd.py", line 96, in run
[2011-06-05 19:59:28,495: WARNING/MainProcess] return self.app.Worker(**kwargs).run()
[2011-06-05 19:59:28,495: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/apps/worker.py", line 135, in run
[2011-06-05 19:59:28,495: WARNING/MainProcess] self.run_worker()
[2011-06-05 19:59:28,495: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/apps/worker.py", line 235, in run_worker
[2011-06-05 19:59:28,495: WARNING/MainProcess] worker.start()
[2011-06-05 19:59:28,495: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/worker/__init__.py", line 250, in start
[2011-06-05 19:59:28,495: WARNING/MainProcess] blocking(component.start)
[2011-06-05 19:59:28,495: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/syn.py", line 14, in blocking
[2011-06-05 19:59:28,495: WARNING/MainProcess] return __sync_current(fun, *args, **kwargs)
[2011-06-05 19:59:28,495: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/syn.py", line 30, in __blocking__
[2011-06-05 19:59:28,496: WARNING/MainProcess] return fun(*args, **kwargs)
[2011-06-05 19:59:28,496: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/worker/consumer.py", line 275, in start
[2011-06-05 19:59:28,496: WARNING/MainProcess] self.consume_messages()
[2011-06-05 19:59:28,496: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/celery/worker/consumer.py", line 291, in consume_messages
[2011-06-05 19:59:28,496: WARNING/MainProcess] self.connection.drain_events(timeout=1)
[2011-06-05 19:59:28,496: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/connection.py", line 139, in drain_events
[2011-06-05 19:59:28,496: WARNING/MainProcess] return self.transport.drain_events(self.connection, **kwargs)
[2011-06-05 19:59:28,496: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/transport/virtual/__init__.py", line 651, in drain_events
[2011-06-05 19:59:28,497: WARNING/MainProcess] item, channel = self.cycle.get(timeout=timeout)
[2011-06-05 19:59:28,497: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/transport/pyredis.py", line 106, in get
[2011-06-05 19:59:28,497: WARNING/MainProcess] self._register_BRPOP(channel)
[2011-06-05 19:59:28,497: WARNING/MainProcess] File "/Users/shubham/.virtualenvs/ts/lib/python2.6/site-packages/kombu/transport/pyredis.py", line 86, in _register_BRPOP
[2011-06-05 19:59:28,497: WARNING/MainProcess] if channel.client.connection._sock is None or \
[2011-06-05 19:59:28,497: WARNING/MainProcess] AttributeError
[2011-06-05 19:59:28,497: WARNING/MainProcess] :
[2011-06-05 19:59:28,497: WARNING/MainProcess] 'Redis' object has no attribute 'connection'
[2011-06-05 19:59:28,498: INFO/MainProcess] process shutting down
[2011-06-05 19:59:28,498: INFO/MainProcess] process shutting down
[2011-06-05 19:59:28,499: INFO/MainProcess] calling join() for process Beat
[2011-06-05 19:59:28,499: INFO/MainProcess] calling join() for process Beat

Deserialize exception when message is empty

I use kombu 1.4.1 with RabbitMQ

When message is send with an empty size, the default serialiser json return an exception. No problem to catch it, but we cannot ACK that we receive the message, and it was block in the Queue, and the purge cannot perform, because we may have some legitimate messages.

Traceback (most recent call last):
File "receipt_diffusion3.py", line 53, in
connection.drain_events()
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/connection.py", line 175, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/transport/pyamqplib.py", line 238, in drain_events
return connection.drain_events(**kwargs)
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/transport/pyamqplib.py", line 57, in drain_events
return self.wait_multi(self.channels.values(), timeout=timeout)
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/transport/pyamqplib.py", line 84, in wait_multi
return amqp_method(channel, args, content)
File "/home/alncchau/.local/lib/python2.6/site-packages/amqplib-1.0.2-py2.6.egg/amqplib/client_0_8/channel.py", line 2060, in _basic_deliver
func(msg)
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/messaging.py", line 446, in _receive_callback
decoded = message.payload
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/transport/base.py", line 159, in payload
self._decoded_cache = self.decode()
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/transport/base.py", line 148, in decode
self.content_encoding)
File "/home/alncchau/.local/lib/python2.6/site-packages/kombu-1.4.1-py2.6.egg/kombu/serialization.py", line 149, in decode
return decoder(data)
File "/home/alncchau/.local/lib/python2.6/site-packages/anyjson-0.3.1-py2.6.egg/anyjson/init.py", line 130, in
deserialize = lambda value: implementation.deserialize(value)
File "/home/alncchau/.local/lib/python2.6/site-packages/anyjson-0.3.1-py2.6.egg/anyjson/init.py", line 99, in deserialize
raise ValueError(*exc.args)
ValueError: No JSON object could be decoded: line 1 column 0 (char 0)

I think, the good method to treat an empty message (when header containt json, pickle, yaml) is to return None type

I have fix this issue in my branch and push it quickly (see below output come from the sample example)

Received message: None
-> properties:
{ 'content_encoding': u'utf-8',
'content_type': u'application/json',
'message_id': u'f7e16ee2-fb3d-11e0-ab83-0010c0a8976f'}
-> delivery_info:
{ 'channel': <kombu.transport.pyamqplib.Channel object at 0xa54266c>,
'consumer_tag': u'1',
'delivery_tag': 1,
'exchange': u'eshop.ezpublish.output',
'redelivered': True,
'routing_key': u'partner.retrieve'}

Regards,

missing exceptions.InvalidData class

in file transport/pyredis.py:345 using class exceptions.InvalidData from redis package which is not exist in redis 2.2.4.

hack: add dummy InvalidData in redis/exception.

Serialization failure in pyredis transport

I have put traceback excerpt to Gist https://gist.github.com/881008

It will reproduce for any body containing unicode string with characters whose ordinals higher than 0x80. Saying it in other way, passing unicode string with such characters as argument to any delayed celery task will result in serialization error in kombu and redis setup.

Should pickled payload be encoded with base64?

When using SQS in fanout mode, SimpleDB records queue names differently than SQS

I've noticed that when using the HEAD of Master (8537a35) and the SQS transport in the default mode of supports_fanout, I get these records in SimpleDB:

pattern=[], id=[c0b86ff4-ea51-4419-9a30-945ed53cf078], routing_key=[], queue=[ip-10-84-66-107.celeryd.pidbox], exchange=[celeryd.pidbox]

The queue name is actually ip-10-84-66-107-celeryd-pidbox (without the dots).

I don't know if this causes a problem - but I imagine it could.

Different message obj when starting consumer through Queue or using Consumer

I dont know if this is a bug or a feature but posting it just in case.

If I create a Queue object and register a consumer by calling queueObj.consume(), the Message object received by the callback is different than if I register a consumer by creating a Consumer object and then calling consumerObj.consume().

I did not look into exactly what was different but I noticed since in the first case msgObj.ack() causes an AttributeError while in the second case it works fine. (default transport)

If its a feature its in any case an undocumented one :)

Heartbeat support

Hi,,

Heartbeat support would be a nice feature to have in kombu and later in celery, I can't find the way to do it right now, and I can't find it in the code, so I imagine is not supported already, I'm getting a lot of blocked queues because of network outages that disconnects in a non nicely way my clients from rabbitmq. I think that with this feature those problems will go away.

Bye.

Multiple routing_keys supported by a consumer

Hi,

Can you please provide me with a small example showing this and tell me if Kombu is production grade already (we are using Carrot but I don't mind switching if this functionality is supported and it's stable already).

Very best regards,
-Stefan Baxter

Redis backend suddenly crashed - unable to start celeryd

Hi Ask,
I had a working redis/celeryd + celerybeat working for some on same server ubuntu lucud 10.04 but it suddenly crashed (possibly due to out of memory error) and I am unable to restart celeryd. Current logs are:

[2011-03-19 12:01:54,075: INFO/PoolWorker-1] child process calling self.run()
[2011-03-19 12:01:54,076: INFO/PoolWorker-2] child process calling self.run()
[2011-03-19 12:01:54,077: INFO/PoolWorker-3] child process calling self.run()
[2011-03-19 12:01:54,078: INFO/PoolWorker-4] child process calling self.run()
[2011-03-19 12:01:54,079: INFO/PoolWorker-5] child process calling self.run()
[2011-03-19 12:01:54,080: INFO/PoolWorker-6] child process calling self.run()
[2011-03-19 12:01:54,081: WARNING/MainProcess] [email protected] has started.
[2011-03-19 12:01:54,086: WARNING/MainProcess] Traceback (most recent call last):
[2011-03-19 12:01:54,087: WARNING/MainProcess] File "/usr/local/bin/celeryd", line 9, in 
[2011-03-19 12:01:54,087: WARNING/MainProcess] load_entry_point('celery==2.2.4', 'console_scripts', 'celeryd')()
[2011-03-19 12:01:54,087: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/bin/celeryd.py", line 186, in m
[2011-03-19 12:01:54,087: WARNING/MainProcess] worker.execute_from_commandline()
[2011-03-19 12:01:54,087: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/bin/base.py", line 54, in execu
[2011-03-19 12:01:54,087: WARNING/MainProcess] return self.handle_argv(prog_name, argv[1:])
[2011-03-19 12:01:54,087: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/bin/base.py", line 44, in handl
[2011-03-19 12:01:54,087: WARNING/MainProcess] return self.run(*args, **vars(options))
[2011-03-19 12:01:54,087: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/bin/celeryd.py", line 95, in ru
[2011-03-19 12:01:54,088: WARNING/MainProcess] return self.app.Worker(**kwargs).run()
[2011-03-19 12:01:54,088: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/apps/worker.py", line 135, in r
[2011-03-19 12:01:54,088: WARNING/MainProcess] self.run_worker()
[2011-03-19 12:01:54,088: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/apps/worker.py", line 235, in r
[2011-03-19 12:01:54,088: WARNING/MainProcess] worker.start()
[2011-03-19 12:01:54,088: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/worker/__init__.py", line 247,
[2011-03-19 12:01:54,088: WARNING/MainProcess] blocking(component.start)
[2011-03-19 12:01:54,088: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/syn.py", l
[2011-03-19 12:01:54,088: WARNING/MainProcess] return __sync_current(fun, *args, **kwargs)
[2011-03-19 12:01:54,089: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/syn.py", l
[2011-03-19 12:01:54,089: WARNING/MainProcess] return fun(*args, **kwargs)
[2011-03-19 12:01:54,089: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/worker/consumer.py", line 264,
[2011-03-19 12:01:54,089: WARNING/MainProcess] self.consume_messages()
[2011-03-19 12:01:54,089: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/celery/worker/consumer.py", line 281,
19 12:01:54,089: WARNING/MainProcess] self.connection.drain_events()
[2011-03-19 12:01:54,089: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/connection
[12:01:54,089: WARNING/MainProcess] return self.transport.drain_events(self.connection, **kwargs)
[2011-03-19 12:01:54,089: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/transport/
[2011-03-19 12:01:54,090: WARNING/MainProcess] self._callbacks[queue](message)
[2011-03-19 12:01:54,090: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/transport/
[2011-03-19 12:01:54,090: WARNING/MainProcess] message = self.Message(self, raw_message)
[2011-03-19 12:01:54,090: WARNING/MainProcess] File "/usr/local/lib/python2.6/dist-packages/kombu-1.0.5-py2.6.egg/kombu/transport/
[2011-03-19 12:01:54,090: WARNING/MainProcess] properties = payload["properties"]
[2011-03-19 12:01:54,090: WARNING/MainProcess] KeyError
[2011-03-19 12:01:54,090: WARNING/MainProcess] :
[2011-03-19 12:01:54,090: WARNING/MainProcess] 'properties'
[2011-03-19 12:01:54,091: INFO/MainProcess] process shutting down

Exchange and Queue do not respect exchange.auto_declare = False

Users with limited permissions often cannot create exchanges, although they can still create queues. The auto_declare on the Exchange is not respected. Moreover, the Queue's declare function calls exchange.declare(). Both break kombu when users do not permission to create exchanges.

Here

diff --git a/kombu/entity.py b/kombu/entity.py
index 6f61f5b..5263b95 100644
--- a/kombu/entity.py
+++ b/kombu/entity.py
@@ -353,10 +353,9 @@ class Queue(MaybeChannelBound):
         self.exchange = self.exchange(self.channel)
 
     def declare(self, nowait=False):
-        """Declares the queue, the exchange and binds the queue to
+        """Declares the queue and binds the queue to
         the exchange."""
-        return (self.exchange and self.exchange.declare(nowait),
-                self.name and self.queue_declare(nowait, passive=False),
+        return (self.name and self.queue_declare(nowait, passive=False),
                 self.name and self.queue_bind(nowait))
 
     def queue_declare(self, nowait=False, passive=False):
diff --git a/kombu/messaging.py b/kombu/messaging.py
index 021abc1..52ed7de 100644
--- a/kombu/messaging.py
+++ b/kombu/messaging.py
@@ -69,7 +69,8 @@ class Producer(object):
             self.auto_declare = auto_declare
 
         self.exchange = self.exchange(self.channel)
-        self.auto_declare and self.declare()
+        if self.auto_declare:
+            self.declare()
 
         if self.on_return:
             self.channel.events["basic_return"].append(self.on_return)

Calling queue.consume with default consumer_tag causes crash

Hello,

According to the documentation for the optional consumer_tag parameter to queue.consume():

"If this field is empty the server will generate a unique tag."

However, if you dont specify one the default is None and this causes a crash in :
File "C:\Python26\lib\site-packages\amqplib\client_0_8\channel.py", line 1847, in basic_consume

at: args.write_shortstr(consumer_tag)

Passing an empty string just causes an empty string to be written. So it does not seem like anything is generated

Cheers
Dirk

No way to set mongodb database name

There doesn't seem to be any way to mark the database name in mongodb.

The connection is set up like:
mongoconn = Connection(host=conninfo.hostname, port=conninfo.port)

It would be good if there was some way we could set this explicitly...

reply_to property lost with pika backend

in pypika.py line 32:

    channel_id, method, props, body = amqp_message

I have verified with a debugger that props contains a reply_to property (set by a different process using kombu/amqplib). However, this property is lost when constructing the Message object.

A dirty hack is just to change:

    kwargs.update({"body": body,
                   "delivery_tag": method.delivery_tag,
                    ..

Into:

    kwargs.update({"properties" : {"reply_to": props.reply_to},
                                 "body": body,
                                 "delivery_tag": method.delivery_tag,
                                  ..

and it all works. However, this of course assumes reply_to is always available and any other properties are still lost.

Cheers
Dirk

templates/index.html not found

after a:

git clone http://github.com/ask/celerymon.git
python setup.py build && python setup.py install
cd /path/to/somewhere
celerymon

The index page (http://localhost:8989) trow and error because the template can't be found:

IOError: [Errno 2] No such file or directory: '/tmp/celerymon/env/lib/python2.6/site-packages/celerymon-0.2.0-py2.6.egg/celerymonitor/handlers/../templates/index.html'

I've tried to add:

recursive-include celerymonitor/templates *.html

in MANIFEST.in but it don't work

Broken pipe after rabbitmq restart not detected immediately

Hello!
I'm using kombu 1.2.1 and amqplib1.0 and python 2.6.1 and rabbitmq 2.5.1.

After a restart of rabbitmq (single node setup) the first call to producer.publish silently returns without transmitting the message. On the second call, I get a "broken pipe" exception, and I recreate the connection and everything works fine.

Why don't I get a broken pipe on the first call?
Is this a problem with amqlib or with kombu?
I've tried to use the ensure* methods on connection, but no luck. It seems that kombu/amqlib don't understand that the socket is dead.

Thanks / J

Can't prevent Kombu from attempting content decoding

We've been trying to send base64 encoded content that should not be decoded, yet Kombu tries to decode it... and fails.

When looking through the code, I saw on line 95 of kombu/serialization.py this bit:

    # Don't decode 8-bit strings or unicode objects
    if content_encoding not in ('binary', 'ascii-8bit') and \
            not isinstance(data, unicode):
        data = codecs.decode(data, content_encoding)

So, the doc string says not to decode 8-bit strings OR unicode objects, but the actual code requires it to be 8-bit AND not unicode to avoid this. Is the code wrong, or is the doc string? And how do I actually make Kombu not decode it, as its currently ignoring the binary content encoding (probably because the data is not a unicode instance).

queue.unbind() calls missing Channel.queue_unbind

Unbinding a routing_key to a queue gives an exception.

queue.unbind()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kombu/entity.py", line 464, in unbind
return self.channel.queue_unbind(queue=self.name,
AttributeError: 'Channel' object has no attribute 'queue_unbind'

delivery_mode does not get passed along to amqp correctly

kombu.transport.pyamqplib passes the "properties" variable to ampq.Message(..) without prefixing a **. ampq.Message does not see the delivery_mode parameter because it encounters a dictionary, so no messages are published with a "delivery_mode" parameter, so no messages survive a restart of rabbitmq. I fixed this by prefixing the properties parameter:

In pyamqlib.py Channel class, I changed the call to amqp.Message(..) by moving the "properties" parameter to the end and prefixing it with **. This allowed delivery_mode flag to make it to rabbitmq and persist messages across rabbitmq restarts.

    return amqp.Message(message_data, priority=priority,
                        content_type=content_type,
                        content_encoding=content_encoding,
                        application_headers=headers,**properties)

-Andrew Dowds (ad80)

Exposure of AMQP transactions (tx.commit/select/rollback)

I cant seem to find any documentation on using AMQP transactions (*) through the Kombu api. This page:

http://packages.python.org/kombu/reference/kombu.transport.virtual.html?highlight=transaction

talks about appending a message to the transactional state but it does not seem related.

I know the pika backend supports them and I am quite sure the amqplib backend (which Im currently using) does too but I dont yet see how this is exposed in Kombu.

(*) http://www.rabbitmq.com/amqp-0-9-1-quickref.html#class.tx

Support new connection pool in redis-py

Looks like the new redis-py connection pool breaks current implementation:

[2011-06-08 14:57:01,629: WARNING/MainProcess] Traceback (most recent call last):
[2011-06-08 14:57:01,631: WARNING/MainProcess] File "/Applications/eclipse/plugins/org.python.pydev.debug_2.1.0.2011052613/pysrc/pydevd.py", line 1141, in
[2011-06-08 14:57:01,632: WARNING/MainProcess] debugger.run(setup['file'], None, None)
[2011-06-08 14:57:01,633: WARNING/MainProcess] File "/Applications/eclipse/plugins/org.python.pydev.debug_2.1.0.2011052613/pysrc/pydevd.py", line 925, in run
[2011-06-08 14:57:01,633: WARNING/MainProcess] pydev_imports.execfile(file, globals, locals) #execute the script
[2011-06-08 14:57:01,634: WARNING/MainProcess] File "/src/manage.py", line 11, in
[2011-06-08 14:57:01,634: WARNING/MainProcess] execute_manager(settings)
[2011-06-08 14:57:01,635: WARNING/MainProcess] File "lib/python2.7/site-packages/django/core/management/init.py", line 438, in execute_manager
[2011-06-08 14:57:01,635: WARNING/MainProcess] utility.execute()
[2011-06-08 14:57:01,636: WARNING/MainProcess] File "lib/python2.7/site-packages/django/core/management/init.py", line 379, in execute
[2011-06-08 14:57:01,637: WARNING/MainProcess] self.fetch_command(subcommand).run_from_argv(self.argv)
[2011-06-08 14:57:01,637: WARNING/MainProcess] File "lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
[2011-06-08 14:57:01,638: WARNING/MainProcess] self.execute(_args, *_options.dict)
[2011-06-08 14:57:01,638: WARNING/MainProcess] File "lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
[2011-06-08 14:57:01,641: WARNING/MainProcess] output = self.handle(_args, *_options)
[2011-06-08 14:57:01,642: WARNING/MainProcess] File "lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 21, in handle
[2011-06-08 14:57:01,642: WARNING/MainProcess] worker.run(_args, _options)
[2011-06-08 14:57:01,643: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/bin/celeryd.py", line 96, in run
[2011-06-08 14:57:01,643: WARNING/MainProcess] return self.app.Worker(
_kwargs).run()
[2011-06-08 14:57:01,644: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/apps/worker.py", line 135, in run
[2011-06-08 14:57:01,656: WARNING/MainProcess] self.run_worker()
[2011-06-08 14:57:01,656: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/apps/worker.py", line 235, in run_worker
[2011-06-08 14:57:01,657: WARNING/MainProcess] worker.start()
[2011-06-08 14:57:01,658: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/worker/init.py", line 250, in start
[2011-06-08 14:57:01,659: WARNING/MainProcess] blocking(component.start)
[2011-06-08 14:57:01,670: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/syn.py", line 14, in blocking
[2011-06-08 14:57:01,670: WARNING/MainProcess] return __sync_current(fun, *args, *_kwargs)
[2011-06-08 14:57:01,676: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/syn.py", line 30, in blocking
[2011-06-08 14:57:01,677: WARNING/MainProcess] return fun(_args, *_kwargs)
[2011-06-08 14:57:01,677: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/worker/consumer.py", line 275, in start
[2011-06-08 14:57:01,678: WARNING/MainProcess] self.consume_messages()
[2011-06-08 14:57:01,678: WARNING/MainProcess] File "lib/python2.7/site-packages/celery/worker/consumer.py", line 291, in consume_messages
[2011-06-08 14:57:01,679: WARNING/MainProcess] self.connection.drain_events()
[2011-06-08 14:57:01,680: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/connection.py", line 139, in drain_events
[2011-06-08 14:57:01,681: WARNING/MainProcess] return self.transport.drain_events(self.connection, **kwargs)
[2011-06-08 14:57:01,681: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/transport/virtual/init.py", line 651, in drain_events
[2011-06-08 14:57:01,702: WARNING/MainProcess] item, channel = self.cycle.get(timeout=timeout)
[2011-06-08 14:57:01,704: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/transport/pyredis.py", line 106, in get
[2011-06-08 14:57:01,705: WARNING/MainProcess] self._register_BRPOP(channel)
[2011-06-08 14:57:01,706: WARNING/MainProcess] File "lib/python2.7/site-packages/kombu/transport/pyredis.py", line 86, in _register_BRPOP
[2011-06-08 14:57:01,707: WARNING/MainProcess] if channel.client.connection._sock is None or
[2011-06-08 14:57:01,708: WARNING/MainProcess] AttributeError
[2011-06-08 14:57:01,709: WARNING/MainProcess] :
[2011-06-08 14:57:01,709: WARNING/MainProcess] 'Redis' object has no attribute 'connection'

AMQP Connection Pool Broken from 1.2.1 to 1.4.0?

Hello!

I use Celery 2.3.0 which installed Kombu 1.4.0 alongside it on a new web server. I noticed our web server latencies were much higher than normal on this machine. In the logs I noticed a lot of this:

2011-09-23 19:26:58,509 - amqplib - connection:661 - DEBUG - Start from server, version: 8.0, properties: {u'information': u'Licensed under the MPL.  See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2011 VMware, Inc.', u'capabilities': {}, u'platform': u'Erlang/OTP', u'version': u'2.5.1'}, mechanisms: [u'PLAIN', u'AMQPLAIN'], locales: [u'en_US']
2011-09-23 19:26:58,513 - amqplib - connection:507 - DEBUG - Open OK! known_hosts []
2011-09-23 19:26:58,513 - amqplib - channel:70 - DEBUG - using channel_id: 1
2011-09-23 19:26:58,516 - amqplib - channel:484 - DEBUG - Channel open

This would happen constantly as we received requests and was killing our response rate.

I downgraded specifically to this commit (the commit our previous web servers were at) part of version 1.2.1: 4faf662

This fixed the issue and connection pooling began to work again. Note that between these changes the celeryconfig.py didn't change at all. And we have BROKER_POOL_LIMIT of 10 in it.

Could you please investigate this regression? I'll do my best to try to nail down a specific version it occurred as well.

Best,
Mitchell

kombu.tests.test_transport_pyredis.test_Redis.test_publish__get fails (with cjson)

Running on python-2.6.6 in Debian Squeeze (again inside build-chroot) this unit test fails because the message body is not decoded. Looking at the test with pdb shows that self.queue(channel).get().payload returns u'{"hello": "world"}' instead of the expected dictionary. Running it outside the chroot does not trigger this problem.

FAIL: test_publish__get (kombu.tests.test_transport_pyredis.test_Redis)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/buildd/kombu-1.0.2/kombu/tests/test_transport_pyredis.py", line 213, in test_publish__get
    {"hello": "world"})
AssertionError: False is not True : First argument is not a dictionary
    'False is not True : First argument is not a dictionary' = self._formatMessage('False is not True : First argument is not a dictionary', "%s is not True" % safe_repr(False))
>>  raise self.failureException('False is not True : First argument is not a dictionary')

SQS backend repeats jobs

Using the SQS backend, a job will complete, and then get pulled again after the time interval of the visibility timeout of the queue. One idea of what's causing this problem is that kombu is not correctly/reliably telling SQS this job has been completed, but that's just an idea.

Happy to do some research into this issue, but I'm not exactly sure where to start looking.

Redis channel blocking when joining new queue

Brief scenario of what the code is doing::

cset = panel.consumer.task_consumer
declaration = dict(queue=queue_name, exchange_type='direct')
queue = cset.add_consumer_from_dict(**declaration)

# we shouldn't have to do this either, but it's a bug in the current release of Celery
queue(cset.channel).declare() # blocks for some lengthy timeout

cset.consume()

Now this eventually gets down to doing a _size() call on the Redis backend, but it seems the backend is in BRPOP mode (whereas in all other cases it was showing as in LISTEN mode. The code is a bit beyond my understanding, but the BRPOP blocks (using kqueue in my instance, I tried eventlet and it failed with separate issues).

I also tried grabbing another channel to declare the queue under (one that wasint in BRPOP), and it went through successfully but failed to actually declare the channel on the consumer (to the point of it actually consuming the newly registered tasks in that queue).

Reference cycle in Channel object

I forget exactly what the reference cycle was, but I fixed it locally by overloading Channel.close to call super and also set self.exchange_types to {}. I thought you should know in case you hadn't noticed this yet. It was causing Channel objects to never be garbage collected (and I was creating quite a lot of them).

KeyError when acknowledging message in SQS

When attempting to use SQS with celery, I am recieving this error and stack trace when celery attempts to acknowledge a message:

Pool callback raised exception: Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/celery/concurrency/base.py", line 113, in safe_apply_callback
fun(*args)
File "/usr/lib/pymodules/python2.7/celery/worker/job.py", line 458, in on_success
self.acknowledge()
File "/usr/lib/pymodules/python2.7/celery/worker/job.py", line 523, in acknowledge
self.on_ack()
File "/usr/lib/pymodules/python2.7/celery/worker/consumer.py", line 398, in ack
message.ack()
File "/usr/lib/pymodules/python2.7/kombu/transport/base.py", line 106, in ack
self.channel.basic_ack(self.delivery_tag)
File "/usr/lib/pymodules/python2.7/kombu/transport/SQS.py", line 229, in basic_ack
delivery_info = self.qos.get(delivery_tag).delivery_info
File "/usr/lib/pymodules/python2.7/kombu/transport/virtual/init.py", line 109, in get
return self._delivered[delivery_tag]
KeyError: 1

This occurs frequently (with different delivery_tags). I think messages are not being deleted off of the queue due to this error.

I am using kombu version 1.2.1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.