Commit 9bc69196 authored by feld's avatar feld
Browse files

Add utility function to return infinite timeout for SQL transactions if we...

Add utility function to return infinite timeout for SQL transactions if we detect it was called from a Mix Task
parent 0effcd2c
......@@ -63,4 +63,13 @@ def posix_error_message(code) when code in @posix_error_codes do
end
def posix_error_message(_), do: ""
def query_timeout do
{parent, _, _, _} = Process.info(self(), :current_stacktrace) |> elem(1) |> Enum.fetch!(2)
cond do
parent |> to_string |> String.starts_with?("Elixir.Mix.Task") -> [timeout: :infinity]
true -> [timeout: 15_000]
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment