Skip to content

Commit c162968

Browse files
committed
Close reader
1 parent ceea1ea commit c162968

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

examples.livemd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ Stream.unfold(%{}, fn _state ->
590590
Boombox.write(writer, packet)
591591

592592
if :finished in [result1, result2] do
593+
if result1 == :ok, do:
594+
Boombox.close(writer1)
595+
if result2 == :ok, do:
596+
Boombox.close(writer2)
593597
nil
594598
else
595599
{nil, %{}}

lib/boombox.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ defmodule Boombox do
371371
end
372372

373373
@doc """
374-
Gracefully terminates Boombox when using `:reader` or `:writer` endpoints.
374+
Gracefully terminates Boombox when using `:reader` or `:writer` endpoints before a response
375+
of type `:finished` has been received.
375376
376377
When using `:reader` endpoint on output informs Boombox that no more packets will be read
377378
from it with `read/1` and that it should terminate accordingly.

0 commit comments

Comments
 (0)