Skip to content

Commit 96e7b8a

Browse files
committed
Close reader
1 parent f0eaefa commit 96e7b8a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
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.

lib/boombox/server.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,6 @@ defmodule Boombox.Server do
442442
end
443443
end
444444

445-
defp elixir_endpoint?({type, _opts}) when type in [:reader, :writer, :message],
446-
do: true
447-
448-
defp elixir_endpoint?(_io), do: false
449-
450445
@spec consuming_boombox_run(boombox_opts(), pid()) :: :ok
451446
defp consuming_boombox_run(boombox_opts, server_pid) do
452447
Stream.resource(

0 commit comments

Comments
 (0)