mirror of https://github.com/celery/kombu.git
gen_unique_id() -> uuid() (but both avail. for compat.)
This commit is contained in:
parent
795cfe8efd
commit
e0bd3e52c8
24
Changelog
24
Changelog
|
@ -2,6 +2,30 @@
|
|||
Change history
|
||||
================
|
||||
|
||||
.. _version-1.3.1:
|
||||
|
||||
1.3.1
|
||||
=====
|
||||
:release-date: 2011-10-07 03:00 P.M BST
|
||||
|
||||
* Last release broke after fork for pool reinitialization.
|
||||
|
||||
* Producer/Consumer now has a ``connection`` attribute,
|
||||
giving access to the :class:`BrokerConnection` of the
|
||||
instance.
|
||||
|
||||
* Pika: Channels now have access to the underlying
|
||||
:class:`BrokerConnection` instance using ``channel.connection.client``.
|
||||
|
||||
This was previously required by the ``Simple`` classes and is now
|
||||
also required by :class:`Consumer` and :class:`Producer`.
|
||||
|
||||
* Connection.default_channel is now closed at object revival.
|
||||
|
||||
* Adds kombu.clocks.LamportClock.
|
||||
|
||||
* compat.entry_to_queue has been moved to new module :mod:`kombu.common`.
|
||||
|
||||
.. _version-1.3.0:
|
||||
|
||||
1.3.0
|
||||
|
|
|
@ -16,7 +16,7 @@ from itertools import count
|
|||
|
||||
from kombu.entity import Exchange, Queue
|
||||
from kombu.messaging import Consumer, Producer
|
||||
from kombu.utils import gen_unique_id, kwdict
|
||||
from kombu.utils import kwdict, uuid
|
||||
|
||||
|
||||
class Node(object):
|
||||
|
@ -205,7 +205,7 @@ class Mailbox(object):
|
|||
def _broadcast(self, command, arguments=None, destination=None,
|
||||
reply=False, timeout=1, limit=None, callback=None, channel=None):
|
||||
arguments = arguments or {}
|
||||
reply_ticket = reply and gen_unique_id() or None
|
||||
reply_ticket = reply and uuid() or None
|
||||
|
||||
if destination is not None and \
|
||||
not isinstance(destination, (list, tuple)):
|
||||
|
|
|
@ -2,7 +2,7 @@ from kombu.tests.utils import unittest
|
|||
|
||||
from kombu import pidbox
|
||||
from kombu.connection import BrokerConnection
|
||||
from kombu.utils import gen_unique_id
|
||||
from kombu.utils import uuid
|
||||
|
||||
|
||||
class test_Mailbox(unittest.TestCase):
|
||||
|
@ -31,7 +31,7 @@ class test_Mailbox(unittest.TestCase):
|
|||
mailbox = pidbox.Mailbox("test_reply__collect")(self.connection)
|
||||
exchange = mailbox.reply_exchange.name
|
||||
|
||||
ticket = gen_unique_id()
|
||||
ticket = uuid()
|
||||
mailbox.get_reply_queue(ticket)(self.connection.channel()).declare()
|
||||
mailbox._publish_reply({"foo": "bar"}, exchange, ticket)
|
||||
_callback_called = [False]
|
||||
|
@ -45,7 +45,7 @@ class test_Mailbox(unittest.TestCase):
|
|||
self.assertEqual(reply, [{"foo": "bar"}])
|
||||
self.assertTrue(_callback_called[0])
|
||||
|
||||
ticket = gen_unique_id()
|
||||
ticket = uuid()
|
||||
mailbox.get_reply_queue(ticket)(self.connection.channel()).declare()
|
||||
mailbox._publish_reply({"biz": "boz"}, exchange, ticket)
|
||||
reply = mailbox._collect(ticket, limit=1, channel=channel)
|
||||
|
|
|
@ -2,7 +2,7 @@ from kombu.tests.utils import unittest
|
|||
|
||||
from kombu.connection import BrokerConnection
|
||||
from kombu.transport import virtual
|
||||
from kombu.utils import gen_unique_id
|
||||
from kombu.utils import uuid
|
||||
|
||||
from kombu.tests.utils import redirect_stdouts
|
||||
|
||||
|
@ -53,23 +53,23 @@ class test_QoS(unittest.TestCase):
|
|||
|
||||
self.assertTrue(self.q.can_consume())
|
||||
for i in range(self.q.prefetch_count - 1):
|
||||
self.q.append(i, gen_unique_id())
|
||||
self.q.append(i, uuid())
|
||||
self.assertTrue(self.q.can_consume())
|
||||
self.q.append(i + 1, gen_unique_id())
|
||||
self.q.append(i + 1, uuid())
|
||||
self.assertFalse(self.q.can_consume())
|
||||
|
||||
tag1 = self.q._delivered.keys()[0]
|
||||
self.q.ack(tag1)
|
||||
self.assertTrue(self.q.can_consume())
|
||||
|
||||
tag2 = gen_unique_id()
|
||||
tag2 = uuid()
|
||||
self.q.append(i + 2, tag2)
|
||||
self.assertFalse(self.q.can_consume())
|
||||
self.q.reject(tag2)
|
||||
self.assertTrue(self.q.can_consume())
|
||||
|
||||
self.q.channel = RestoreChannel(self.q.channel.connection)
|
||||
tag3 = gen_unique_id()
|
||||
tag3 = uuid()
|
||||
self.q.append(i + 3, tag3)
|
||||
self.q.reject(tag3, requeue=True)
|
||||
self.q._flush()
|
||||
|
@ -91,7 +91,7 @@ class test_Message(unittest.TestCase):
|
|||
def test_create(self):
|
||||
c = client().channel()
|
||||
data = c.prepare_message("the quick brown fox...")
|
||||
tag = data["properties"]["delivery_tag"] = gen_unique_id()
|
||||
tag = data["properties"]["delivery_tag"] = uuid()
|
||||
message = c.message_to_python(data)
|
||||
self.assertIsInstance(message, virtual.Message)
|
||||
self.assertIs(message, c.message_to_python(message))
|
||||
|
@ -103,7 +103,7 @@ class test_Message(unittest.TestCase):
|
|||
def test_serializable(self):
|
||||
c = client().channel()
|
||||
data = c.prepare_message("the quick brown fox...")
|
||||
tag = data["properties"]["delivery_tag"] = gen_unique_id()
|
||||
tag = data["properties"]["delivery_tag"] = uuid()
|
||||
message = c.message_to_python(data)
|
||||
dict_ = message.serializable()
|
||||
self.assertEqual(dict_["body"],
|
||||
|
@ -257,7 +257,7 @@ class test_Channel(unittest.TestCase):
|
|||
"nthex quick brown fox...".encode("utf-8"))
|
||||
self.assertIsNone(c.basic_get(n))
|
||||
|
||||
consumer_tag = gen_unique_id()
|
||||
consumer_tag = uuid()
|
||||
|
||||
c.basic_consume(n + "2", False, consumer_tag=consumer_tag,
|
||||
callback=lambda *a: None)
|
||||
|
|
|
@ -87,24 +87,24 @@ class test_UUID(unittest.TestCase):
|
|||
self.assertNotEqual(utils.uuid4(),
|
||||
utils.uuid4())
|
||||
|
||||
def test_gen_unique_id(self):
|
||||
i1 = utils.gen_unique_id()
|
||||
i2 = utils.gen_unique_id()
|
||||
def test_uuid(self):
|
||||
i1 = utils.uuid()
|
||||
i2 = utils.uuid()
|
||||
self.assertIsInstance(i1, str)
|
||||
self.assertNotEqual(i1, i2)
|
||||
|
||||
@skip_if_module('__pypy__')
|
||||
def test_gen_unique_id_without_ctypes(self):
|
||||
def test_uuid_without_ctypes(self):
|
||||
old_utils = sys.modules.pop("kombu.utils")
|
||||
|
||||
@mask_modules("ctypes")
|
||||
def with_ctypes_masked():
|
||||
from kombu.utils import ctypes, gen_unique_id
|
||||
from kombu.utils import ctypes, uuid
|
||||
|
||||
self.assertIsNone(ctypes)
|
||||
uuid = gen_unique_id()
|
||||
self.assertTrue(uuid)
|
||||
self.assertIsInstance(uuid, basestring)
|
||||
tid = uuid()
|
||||
self.assertTrue(tid)
|
||||
self.assertIsInstance(tid, basestring)
|
||||
|
||||
try:
|
||||
with_ctypes_masked()
|
||||
|
|
|
@ -24,7 +24,7 @@ from boto.sqs.connection import SQSConnection
|
|||
from boto.sqs.message import Message
|
||||
|
||||
from kombu.transport import virtual
|
||||
from kombu.utils import cached_property, gen_unique_id
|
||||
from kombu.utils import cached_property, uuid
|
||||
|
||||
|
||||
# dots are replaced by dash, all other punctuation
|
||||
|
@ -60,7 +60,7 @@ class Table(Domain):
|
|||
item = self.get_queue(queue)
|
||||
if item:
|
||||
return item, item["id"]
|
||||
id = gen_unique_id()
|
||||
id = uuid()
|
||||
return self.new_item(id), id
|
||||
|
||||
def queue_bind(self, exchange, routing_key, pattern, queue):
|
||||
|
|
|
@ -24,13 +24,14 @@ def uuid4():
|
|||
return _uuid4()
|
||||
|
||||
|
||||
def gen_unique_id():
|
||||
def uuid():
|
||||
"""Generate a unique id, having - hopefully - a very small chance of
|
||||
collission.
|
||||
|
||||
For now this is provided by :func:`uuid.uuid4`.
|
||||
"""
|
||||
return str(uuid4())
|
||||
gen_unique_id = uuid
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
|
|
Loading…
Reference in New Issue