Skip to content

Commit

Permalink
Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jun 11, 2012
1 parent 807b86c commit d33237a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
19 changes: 11 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,18 @@ Quick overview
# connections
with BrokerConnection("amqp://guest:guest@localhost//") as conn:

# Declare the video queue so that the messages can be delivered.
# It is a best practice in Kombu to have both publishers and
# consumers declare the queue.
video_queue(conn.channel()).declare()

# produce
with conn.Producer(exchange=media_exchange,
serializer="json", routing_key="video") as producer:
producer.publish({"name": "/tmp/lolcat1.avi", "size": 1301013})
with conn.Producer(serializer="json") as producer:
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:
Expand Down
8 changes: 2 additions & 6 deletions kombu/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,11 @@ def ChannelPool(self, limit=None, preload=None):

def Producer(self, channel=None, *args, **kwargs):
from .messaging import Producer
if channel is None:
channel = self # use default channel support.
return Producer(channel, *args, **kwargs)
return Producer(channel or self, *args, **kwargs)

def Consumer(self, queues=None, channel=None, *args, **kwargs):
from .messaging import Consumer
if channel is None:
channel = self # use default channel support.
return Consumer(channel, queues, *args, **kwargs)
return Consumer(channel or self, queues, *args, **kwargs)

def SimpleQueue(self, name, no_ack=None, queue_opts=None,
exchange_opts=None, channel=None, **kwargs):
Expand Down

0 comments on commit d33237a

Please sign in to comment.