Skip to content

Commit

Permalink
Use Keyword.put_new and avoid single use timeout var
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Sep 6, 2024
1 parent c096b55 commit 071c5d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/flame/pool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ defmodule FLAME.Pool do
track_resources ->
place_opts =
opts
|> Keyword.put(:timeout, opts[:timeout] || remaining_timeout)
|> Keyword.put(:track_resources, track_resources)
|> Keyword.put_new(:timeout, remaining_timeout)
|> Keyword.put_new(:link, true)

case Runner.place_child(runner_pid, child_spec, place_opts) do
Expand Down
5 changes: 2 additions & 3 deletions lib/flame/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule FLAME.Runner do
backend_init: nil,
node_name: nil,
single_use: false,
timeout: 20_000,
timeout: 30_000,
status: nil,
log: :info,
boot_timeout: 10_000,
Expand Down Expand Up @@ -118,11 +118,10 @@ defmodule FLAME.Runner do
def call(runner_pid, caller_pid, func, opts \\ [])
when is_pid(runner_pid) and is_pid(caller_pid) and is_function(func) and is_list(opts) do
link? = Keyword.get(opts, :link, true)
timeout = opts[:timeout] || nil
track_resources? = Keyword.get(opts, :track_resources, false)
{ref, %Runner{} = runner, backend_state} = checkout(runner_pid)
%Runner{terminator: terminator} = runner
call_timeout = timeout || runner.timeout
call_timeout = opts[:timeout] || runner.timeout

result =
remote_call(runner, backend_state, call_timeout, track_resources?, fn ->
Expand Down

0 comments on commit 071c5d2

Please sign in to comment.