Skip to content
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

parallel-process returns a lazy seq that is never materialized #4

Open
tampix opened this issue Aug 3, 2021 · 0 comments
Open

parallel-process returns a lazy seq that is never materialized #4

tampix opened this issue Aug 3, 2021 · 0 comments

Comments

@tampix
Copy link

tampix commented Aug 3, 2021

Hello and thanks for your library.

I found something that looks like a bug.

Currently, parallel-process returns a lazy seq, produced by the call to claypoole/upmap.

Consumer code being :

(fn []
  (reset! (:running config) true)
  (while @(:running config)
    ;; neither dequeue or run-dequeue-fn (here core/default-top-level-error-handler)
    ;; read the value returned by process-fn
    (run-dequeue-fn
     #(dequeue config process-fn)))
  (reset! (:finished-shutdown config) true))

This means that dequeue will be called without waiting for materialization of the result of process-fn (here, parallel-process).
This can lead to receiving messages up until reaching SQS Messages in flight limit or saturating the JVM's heap as you can't have any control on the amount of messages hold in memory.

One possible solution would be to force the materialization of the lazy seq with either dorun or doall, which would seem more correct :

  • receive up to 10 messages
  • process them in parallel
  • when all were processed, receive the next 10 messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant