Skip to content

Commit

Permalink
Utils.run_exclusive doesn't not send messages anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne authored and Neylix committed Dec 15, 2023
1 parent 7928960 commit b814fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/archethic/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ defmodule Archethic.Utils do

case Registry.lookup(registry, key) do
[] ->
Task.Supervisor.async_nolink(
Task.Supervisor.start_child(
Archethic.TaskSupervisor,
fn ->
{:ok, _} = Registry.register(registry, key, nil)
Expand Down
14 changes: 14 additions & 0 deletions test/archethic/utils_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ defmodule Archethic.UtilsTest do
refute_receive :bar, 100
end

test "run_exclusive/2 should not send any message" do
me = self()

Utils.run_exclusive(:foo, fn _ ->
send(me, :bar)

# simulate some execution time
Process.sleep(10)
end)

assert_receive :bar, 100
refute_receive _, 100
end

describe "get_current_time_for_interval/2" do
test "should return a value truncated to the minute (* minute)" do
now = DateTime.utc_now()
Expand Down

0 comments on commit b814fc4

Please sign in to comment.