-
Notifications
You must be signed in to change notification settings - Fork 232
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
async iterating over nodes is not working #798
Comments
@AnikinNN Please check the corresponding PR ! |
Great work! I see two points which I should mention:
I can propose better test: @mark_async_test
async def test_async_iterator():
n = 10
if AsyncUtil.is_async_code:
for i in range(n):
await Coffee(name=f"xxx_{i}", price=i).save()
nodes = await Coffee.nodes
# assert that nodes was created
assert isinstance(nodes, list)
assert all(isinstance(i, Coffee) for i in nodes)
assert len(nodes) == n
counter = 0
async for node in Coffee.nodes:
assert isinstance(node, Coffee)
counter += 1
# assert that generator runs loop above
assert counter == n |
Yes indeed, I agree with your first point ! To be honest, I focussed here on fixing the As for the test, thank you, I updated it. Re-reading my test, I see it had no assertions and had the try-except still, I don't know what I had in mind 😄 . I guess I was tired from going down into the |
Definitely agree with you |
OK, so let me close this and include it in 5.3.1 ; and then we can open an issue for improving this behaviour. |
Expected Behavior (Mandatory)
It is possible to iterate over nodes in async style
Actual Behavior (Mandatory)
It is not possible to iterate over nodes in async style. You have to fetch all nodes to memory before iteration
How to Reproduce the Problem
Run code below
Simple Example
Specifications (Mandatory)
don't know what I should write here
Currently used versions
Versions
The text was updated successfully, but these errors were encountered: