-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support for async iterators in seq functions #1181
Comments
The problem with Python's async implementation (and why I haven't particularly spent much effort trying to incorporate it into Basilisp) is that functions are "colored" and the specific function color is contagious. Once a function is asynchronous, it can only be used within async contexts (which are the only contexts that can There are many issues that I see arising, but just to give an example: nearly every Basilisp lazy seq function (e.g. I personally am ok with adding async primitives to Basilisp so users can access them (and fixing issues such as #1179 and #1180), but I do not want to infect the core seq library with Python async (absent a detailed analysis of the effects across the entire project). To me it seems like what you are asking for should instead be a separate |
Async generators are not generators, so this is not logically inconsistent. |
Right, thanks for taking the time to explain the situation and highlighting the challenges with async constructs in python. My knowledge of this subject is fairly superficial, but I wanted to bring attention to it as a potential gap. This particular issue caught my attention after reviewing Creating an external library to address this seems like an excellent idea, provided, as you mentioned, that the necessary primitives are in place. Do you have any initial thoughts on how an |
I may be misunderstanding you but I don't think Clojure/Basilisp If you're just talking about how to adapt a Python |
My reasoning was as follows: Python has a primitive I hope this clarifies a bit my train of thought behind to the suggestion. To summarize the options discussed
Does option 2 seem feasible and something that you might consider? Option 1 feels like overkill to me and seems to me. here’s an example of how I imagine (import asyncio afor)
(defasync main
[]
(python/asyncfor [value (afor/agen)]
(println value)))
(asyncio/run (main)) Thanks |
Hi,
Python provides async for to iterate over async iterators.
The documentation at the yield special form suggests that "...Basilisp seq and sequence functions integrate seamlessly with Python generators", but it seems that doesn't cover async generators.
For example, given the following python file which defines an
agen
async generator function, and demonstrate its use:afor.py
when run, it successfully iterates over
agen
However, If i try to do the same over the same async generator
agen
from Basilisp, using aseq
(orvec
), it fails with anasync_generator object is not iterable
error:issuefor.lpy
I'm not sure what the right solution is here. Would it be possible to extend the "seq and sequence functions" as described in the documentation to support async iterators?
Thanks
The text was updated successfully, but these errors were encountered: