From 071c5d265a8ea78e9862651044a7243da85b801c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 6 Sep 2024 11:33:55 +0200 Subject: [PATCH] Use Keyword.put_new and avoid single use timeout var --- lib/flame/pool.ex | 2 +- lib/flame/runner.ex | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/flame/pool.ex b/lib/flame/pool.ex index e276a5b..1767d72 100644 --- a/lib/flame/pool.ex +++ b/lib/flame/pool.ex @@ -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 diff --git a/lib/flame/runner.ex b/lib/flame/runner.ex index f8c54ee..020ad64 100644 --- a/lib/flame/runner.ex +++ b/lib/flame/runner.ex @@ -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, @@ -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 ->