'celery' object has no attribute 'utils

问题:

以前经常使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值