elixir - `Task.async` times out on query inside `Ecto.Multi` in tests -
i'm struggling perform async operation inside 1 of steps in ecto.multi
. here i'll present minimal version describe problem:
defmodule mymodule my_function(repo \\ repo) ecto.multi.new() |> ecto.multi.run(:example, &perform_example(&1, repo)) |> repo.transaction() end def perform_example(_changes_so_far, repo) task.async(fn -> repo.all(datamodule) end) |> io.inspect() # 1. |> task.await() # 2. |> io.inspect() end end mymodule.my_function(repo)
1. seems working correctly yealds task
struct:
%task{owner: #pid<0.352.0>, pid: #pid<0.354.0>, ref: #reference<0.2903625078.3861118978.56327>}
2. unfortunately raises error:
** (exit #pid<0.352.0>) exited in: genserver.call(#pid<0.353.0>, {:checkout, #reference<0.2903625078.3861118978.56400>, true, 15000}, 5000) ** (exit) time out
strangely enough, i've tried perform same code outside multi
, worked correctly... problem problem how multi
works?
i've tried exercise code using related functionality , seemed working correctly. it's issue inside 1 of multi
steps when executing in test environment.
ecto not support multiple processes using single transaction. not clear semantics of such setup , should happen if 1 of processes fails.
Comments
Post a Comment