'celery' object has no attribute 'utils

来源:互联网 发布:淘宝怎么搜好看的衣服 编辑:程序博客网 时间:2024/06/05 23:42

问题:

以前经常使用celery.utils.uuid()获取通用唯一识别码,但在celery 4.1.0中使用时出现报错:

‘celery’ object has no attribute ‘utils

原因:

版本更新导致的不兼容问题。
官方给出的说法:

celery.utils

Utility functions.
Don’t import from here directly anymore, as these are only here for backwards compatibility.

其中关于uuid的解释:

celery.utils.uuid(_uuid=)

Generate unique id in UUID4 format.See also**For now this is provided by uuid.uuid4().**

根据提示,获取通用唯一识别码以后应该使用uuid.uuid4():

>>> import uuid>>> uuid.uuid4()UUID('307a7475-afe7-473a-abac-4d6acad50c7f')>>> str(uuid.uuid4())'7cbab6fa-883c-4970-a0bb-ea16938cc099'>>>

参考:

官方链接
http://docs.celeryproject.org/en/latest/internals/reference/celery.utils.html

原创粉丝点击