简体   繁体   English

"在枚举中调用异步函数"

[英]Call async function in Enum

I want to refactor my code from sync to async.我想将我的代码从同步重构为异步。 I use python and FastApi.我使用 python 和 FastApi。 I use the method which calls async function in Enumaration.我使用枚举中调用异步函数的方法。

for example:例如:

from enum import Enum

from app.story import get_story

    StoriesEnum = Enum(
        "StoriesEnum", {story: story  for story in get_story.story_list},
    )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM