summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-04-20 11:10:39 -0500
committerMark Felder <feld@feld.me>2021-04-22 10:15:50 -0500
commit9bc69196d5dfbd3fb37c0e62da19ce08fb9bf28d (patch)
tree8c096a65c4ea59143d25797d5ba0e12b5d8313be
parent0effcd2cfed36baec1d960b64c901da7e56710a8 (diff)
Add utility function to return infinite timeout for SQL transactions if we detect it was called from a Mix Task
-rw-r--r--lib/pleroma/utils.ex9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/pleroma/utils.ex b/lib/pleroma/utils.ex
index bc0c95332..5e2fa8bf7 100644
--- a/lib/pleroma/utils.ex
+++ b/lib/pleroma/utils.ex
@@ -63,4 +63,13 @@ defmodule Pleroma.Utils 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