diff options
author | Ask Solem <ask@celeryproject.org> | 2014-02-03 15:48:18 +0000 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2014-02-03 15:48:18 +0000 |
commit | 7b48307674b9c6816c63613ae3a7df3a734f2859 (patch) | |
tree | 20210d1c068095ec200c1b76ca627db127a38454 | |
parent | ded9a2b7073b0510c03f9c8ff77a8c7c26de8855 (diff) | |
download | kombu-7b48307674b9c6816c63613ae3a7df3a734f2859.tar.gz |
Use uuid4() instead of uuid.getnode. celery/celery#1822
-rw-r--r-- | kombu/common.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/kombu/common.py b/kombu/common.py index 053fcc26..cac03314 100644 --- a/kombu/common.py +++ b/kombu/common.py @@ -15,7 +15,7 @@ from collections import deque from contextlib import contextmanager from functools import partial from itertools import count -from uuid import getnode as _getnode, uuid3 as _uuid3, NAMESPACE_OID +from uuid import getnode as _getnode, uuid4, uuid3, NAMESPACE_OID from amqp import RecoverableConnectionError @@ -44,10 +44,19 @@ PREFETCH_COUNT_MAX = 0xFFFF logger = get_logger(__name__) +_node_id = None + + +def get_node_id(): + global _node_id + if _node_id is None: + _node_id = uuid4().int + return _node_id + def generate_oid(node_id, process_id, thread_id, instance): - ent = '%x-%x-%x-%x' % (node_id, process_id, thread_id, id(instance)) - return str(_uuid3(NAMESPACE_OID, ent)) + ent = '%x-%x-%x-%x' % (get_node_id(), process_id, thread_id, id(instance)) + return str(uuid3(NAMESPACE_OID, ent)) def oid_from(instance): |