-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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_stream + Stream.run is blocking #8445
Comments
Yes, Stream.run always blocks the caller. The difference to Enum.to_list is that it doesn't have to build a list because you don't care about results. Stream is always about laziness, it never starts processes for you. In your case, you can start a separate process yourself. Just an example, if Stream.run started another process, then your code sample wouldn't work, because the new process wouldn't be inside the transaction (which is per process). |
@josevalim thank you,
Yes, but |
@josevalim As I know they don't work well with Repo.stream elixir-lang/gen_stage#150 Does this still relevant?
|
Ah, yes, you are correct. So you will have to start the process yourself for now but, as I said, if we started the process automatically, which is what Flow/GenStage does, then it wouldn't work with Ecto either. :D The feature you request was not yet implemented, so Ecto 3.1 it is indeed. |
Just wondering why such code:
blocks caller?
Stream.run(stream)
is assuming that I don't care about results so there is no need to wait while all tasks will be finished. So why it act the same asEnum.to_list(stream)
? Is there some way to do it without blocking except starting a separate process?The text was updated successfully, but these errors were encountered: