python 中的辅助函数为正常格式
我正在 arq 工作人员中工作,在测试一些代码时,我得到了这种格式,
JobDef(function=<function helper at 0x7f79b3582f70>, args=(4, 5, 6, 6), kwargs={}, job_try=None, enqueue_time=datetime.datetime(2022, 2, 28, 6, 18, 7, 247000, tzinfo=datetime.timezone.utc), score=1646029087247)
但我需要采用规范化格式,例如
{'args': (4, 5, 6, 6) or [4, 5, 6, 6],
'kwargs': {},
'job_try': None,
'enqueue_time': datetime.datetime(2022, 2, 28, 6, 18, 7, 247000,
tzinfo=datetime.timezone.utc) or 2022, 2, 28, 6, 18, 7, 247000-> correct
date and time,
'score': 1646029087247
}
任何预定义的方法来解决此问题。
i am working in arq worker, while testing some code, i was getting like this format
JobDef(function=<function helper at 0x7f79b3582f70>, args=(4, 5, 6, 6), kwargs={}, job_try=None, enqueue_time=datetime.datetime(2022, 2, 28, 6, 18, 7, 247000, tzinfo=datetime.timezone.utc), score=1646029087247)
But I need in normalize format like
{'args': (4, 5, 6, 6) or [4, 5, 6, 6],
'kwargs': {},
'job_try': None,
'enqueue_time': datetime.datetime(2022, 2, 28, 6, 18, 7, 247000,
tzinfo=datetime.timezone.utc) or 2022, 2, 28, 6, 18, 7, 247000-> correct
date and time,
'score': 1646029087247
}
Any pre-defined way to fix this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我研究了 arq 源代码 和
JobDef< /code> 定义如下,
因此您应该能够将
JobDef
的实例提供给dataclasses.asdict
函数 应该返回字典。考虑以下简化示例输出
I looked into arq source code and
JobDef
is defined as followstherefore you should be able to feed instance of
JobDef
intodataclasses.asdict
function which should returndict
. Consider following simplified exampleoutput