Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/flame/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ defmodule FLAME.Runner do
{ref, %Runner{} = runner, backend_state} = checkout(runner_pid)
%Runner{terminator: terminator} = runner
call_timeout = opts[:timeout] || runner.timeout
callers = [self() | Process.get(:"$callers", [])]

result =
remote_call(runner, backend_state, call_timeout, track_resources?, fn ->
Process.put(:"$callers", callers)
if link?, do: Process.link(caller_pid)
:ok = Terminator.deadline_me(terminator, call_timeout)
if is_function(func, 1), do: func.(terminator), else: func.()
Expand Down
12 changes: 12 additions & 0 deletions test/flame_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ defmodule FLAME.FLAMETest do
end)
end

@tag runner: [min: 1, max: 2, max_concurrency: 2, idle_shutdown_after: 500]
test "sets $callers", %{} = config do
parent = self()
assert FLAME.call(config.test, fn -> Process.get(:"$callers") end) == [parent]

FLAME.cast(config.test, fn ->
send(parent, {:callers, Process.get(:"$callers")})
end)

assert_receive {:callers, [_, ^parent]}
end

describe "cast" do
@tag runner: [min: 1, max: 2, max_concurrency: 2, idle_shutdown_after: 500]
test "normal execution", %{} = config do
Expand Down