I want to refactor my code from sync to async. I use python and FastApi. I use the method which calls async function in Enumaration.
from enum import Enum
from app.story import get_story
StoriesEnum = Enum(
"StoriesEnum", {story: story for story in get_story.story_list},
)
As per the documentation<\/a> :
So, functions with
async def<\/code> can only be called inside of<\/strong> functions defined with<\/strong>
async def<\/code> too.
"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.