Skip to content

Commit a4b01b2

Browse files
author
José Valim
committed
Fix race condition on supervisor test
1 parent b8d02e9 commit a4b01b2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/elixir/test/elixir/supervisor_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ defmodule SupervisorTest do
1515
end
1616

1717
def handle_call(:stop, _from, stack) do
18+
# There is a race condition in between genserver terminations.
19+
# So we will explicitly unregister it here.
1820
try do
19-
# There is a race condition in between genserver terminations.
20-
# So we will explicitly unregister it here.
21-
Process.unregister(:sup_stack)
22-
catch
23-
_, _ -> :ok
21+
self |> Process.info(:registered_name) |> elem(1) |> Process.unregister
22+
rescue
23+
_ -> :ok
2424
end
2525
{:stop, :normal, :ok, stack}
2626
end

0 commit comments

Comments
 (0)