-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start using any io for structured concurency #1065
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
import asyncio | ||
from collections import OrderedDict | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
@@ -18,6 +17,7 @@ | |
) | ||
from typing import OrderedDict as OrderedDictType | ||
|
||
from anyio import create_task_group | ||
from bson import DBRef, ObjectId | ||
from bson.errors import InvalidId | ||
from pydantic import BaseModel | ||
|
@@ -363,10 +363,10 @@ def repack_links( | |
|
||
@classmethod | ||
async def fetch_many(cls, links: List[Link]): | ||
coros = [] | ||
for link in links: | ||
coros.append(link.fetch()) | ||
return await asyncio.gather(*coros) | ||
if links: | ||
async with create_task_group() as tg: | ||
for link in links: | ||
tg.start_soon(link.fetch) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not mistaken (since I don't know anyio), here we should use something else apart from tg.start_soon() since it can't be awaited... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E.g. FastAPI does something like this, lines 856-867: |
||
|
||
if IS_PYDANTIC_V2: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method used to return here previously. I don't see how are the "results" being returned now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. will add test to his this is breaking change