Skip to content

Commit b598df4

Browse files
committed
Manually manage process rather than relying on linking
This prevents the race condition that was causing issues between koans as each is run in its own process.
1 parent 11601a6 commit b598df4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/koans/18_genservers.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ defmodule GenServers do
1212
{:ok, args}
1313
end
1414

15-
def start_link(init_password) do
15+
def start(init_password) do
1616
# The __MODULE__ macro returns the current module name as an atom
17-
GenServer.start_link(__MODULE__, init_password, name: __MODULE__)
17+
GenServer.start(__MODULE__, init_password, name: __MODULE__)
18+
end
19+
20+
def stop do
21+
GenServer.stop(__MODULE__)
1822
end
1923

2024
def unlock(password) do
@@ -151,5 +155,7 @@ defmodule GenServers do
151155

152156
{_, response} = Laptop.owner_name()
153157
assert response == ___
158+
159+
:ok = Laptop.stop()
154160
end
155161
end

0 commit comments

Comments
 (0)