+ def parse_with_timeout(url) do
+ try do
+ task =
+ Task.Supervisor.async_nolink(Pleroma.TaskSupervisor, fn ->
+ parse_url(url)
+ end)
+
+ Task.await(task, 5000)
+ catch
+ :exit, {:timeout, _} ->
+ Logger.warn("Timeout while fetching rich media for #{url}")
+ {:error, :timeout}
+ end
+ end
+