Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 9, 2024
1 parent fb69a7a commit 8d29ca4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 5 additions & 1 deletion lib/broadway.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,11 @@ defmodule Broadway do
@spec all_running() :: [name()]
def all_running do
for {{Broadway, name}, %Broadway.Topology{}} <- :persistent_term.get(),
GenServer.whereis(name),
(try do
GenServer.whereis(name)
rescue
_ -> false
end),
do: name
end

Expand Down
20 changes: 11 additions & 9 deletions lib/broadway/topology.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,21 @@ defmodule Broadway.Topology do
end

@impl true
def terminate(reason, %{name: name, supervisor_pid: supervisor_pid, terminator: terminator}) do
def terminate(reason, %{supervisor_pid: supervisor_pid, terminator: terminator}) do
Broadway.Topology.Terminator.trap_exit(terminator)
ref = Process.monitor(supervisor_pid)
Process.exit(supervisor_pid, reason_to_signal(reason))

# We don't delete from persistent term on purpose. Since the process is
# named, we can assume it does not start dynamically, so it will either
# restart or the amount of memory it uses is negligibla to justify the
# process purging done by persistent_term. If the repo is restarted and
# stores the same metadata, then no purging happens either.
# receive do
# {:DOWN, ^ref, _, _, _} -> :persistent_term.erase({Broadway, name})
# end
receive do
{:DOWN, ^ref, _, _, _} ->
# We don't delete from persistent term on purpose. Since the process is
# named, we can assume it does not start dynamically, so it will either
# restart or the amount of memory it uses is negligibla to justify the
# process purging done by persistent_term. If the repo is restarted and
# stores the same metadata, then no purging happens either.
# :persistent_term.erase({Broadway, name})
:ok
end

:ok
end
Expand Down

0 comments on commit 8d29ca4

Please sign in to comment.