summaryrefslogtreecommitdiff
path: root/kombu/transport/SQS.py
diff options
context:
space:
mode:
authorAsk Solem <ask@celeryproject.org>2011-05-25 14:35:04 +0100
committerAsk Solem <ask@celeryproject.org>2011-05-25 14:46:29 +0100
commit6bcedcbe53ac0153422fae72c093177db28363a3 (patch)
tree5fcb24017ab7e9e25a2d632d623d5b50e51d5b97 /kombu/transport/SQS.py
parent3ec12584f1bcf9251923b9657ff5994a9ce6c64b (diff)
downloadkombu-6bcedcbe53ac0153422fae72c093177db28363a3.tar.gz
SQS transport now replaces dots in queue names with dashes
and also all other punctuation with underscores, as SQS only accepts alphanumerics + -,_. Thanks to adamn
Diffstat (limited to 'kombu/transport/SQS.py')
-rw-r--r--kombu/transport/SQS.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/kombu/transport/SQS.py b/kombu/transport/SQS.py
index 52688f1d..ab8477c8 100644
--- a/kombu/transport/SQS.py
+++ b/kombu/transport/SQS.py
@@ -10,6 +10,7 @@ Amazon SQS transport.
"""
import socket
+import string
from Queue import Empty
@@ -22,11 +23,24 @@ from kombu.transport import virtual
from kombu.utils import cached_property
+# dots are replaced by dash, all other punctuation
+# replaced by underscore.
+CHARS_REPLACE = string.punctuation.replace('-', '') \
+ .replace('_', '') \
+ .replace('.', '')
+CHARS_REPLACE_TABLE = string.maketrans(CHARS_REPLACE + '.',
+ "_" * len(CHARS_REPLACE) + '-')
+
+
class Channel(virtual.Channel):
_client = None
+ def entity_name(self, name, table=CHARS_REPLACE_TABLE):
+ return name.translate(table)
+
def _new_queue(self, queue, **kwargs):
- return self.client.create_queue(queue, self.visibility_timeout)
+ return self.client.create_queue(self.entity_name(queue),
+ self.visibility_timeout)
def _get(self, queue):
q = self._new_queue(queue)