Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add long-polling support to SQS transport #198

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions kombu/transport/SQS.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class Channel(virtual.Channel):

default_region = 'us-east-1'
default_visibility_timeout = 1800 # 30 minutes.
# 20 seconds is the max value currently supported by SQS.
default_wait_time_seconds = 20
domain_format = 'kombu%(vhost)s'
_sdb = None
_sqs = None
Expand Down Expand Up @@ -225,7 +227,7 @@ def _put_fanout(self, exchange, message, **kwargs):
def _get(self, queue):
"""Try to retrieve a single message off ``queue``."""
q = self._new_queue(queue)
rs = q.get_messages(1)
rs = q.get_messages(1, wait_time_seconds=self.wait_time_seconds)
if rs:
m = rs[0]
payload = loads(rs[0].get_body())
Expand Down Expand Up @@ -337,11 +339,17 @@ def supports_fanout(self):
def region(self):
return self.transport_options.get('region') or self.default_region

@cached_property
def wait_time_seconds(self):
return (self.transport_options.get('wait_time_seconds') or
self.default_wait_time_seconds)


class Transport(virtual.Transport):
Channel = Channel

polling_interval = 1
polling_interval = 0
wait_time_seconds = 20
default_port = None
connection_errors = (StdConnectionError, exception.SQSError, socket.error)
channel_errors = (exception.SQSDecodeError, StdChannelError)