You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not clear to me how to handle exceptions inside poolboy workers. I'm using Elixir, but I think this applies to Erlang as well.
My code looks more or less like this:
task=Task.async(fn ->
:poolboy.transaction(:worker,fnpid->trydoGenServer.call(pid,{:someWorkerFunction})catche,r-># reraise e, rendendend)
Task.await(task)
Suppose the worker function throws an exception (i.e. the call with {:someWorkerFunction}). If I comment out reraise e, r as above, worker fails silently and my code continues to run as nothing happened.
However, when I uncomment that reraise e, r statement (or in fact just remove the try...catch block), the worker crashes in such a way that I'm not able to catch it (wrapping Task.await in try...after seems to do nothing).
How should I proceed to be able to recover from such crashes as I need to call some cleanup code? I know the docs say that try...after "provides only a soft guarantee", but I guess I'm bit of a noob to handle this properly.
The text was updated successfully, but these errors were encountered:
Hello,
It's not clear to me how to handle exceptions inside poolboy workers. I'm using Elixir, but I think this applies to Erlang as well.
My code looks more or less like this:
Suppose the worker function throws an exception (i.e. the call with
{:someWorkerFunction}
). If I comment outreraise e, r
as above, worker fails silently and my code continues to run as nothing happened.However, when I uncomment that
reraise e, r
statement (or in fact just remove thetry...catch
block), the worker crashes in such a way that I'm not able to catch it (wrappingTask.await
intry...after
seems to do nothing).How should I proceed to be able to recover from such crashes as I need to call some cleanup code? I know the docs say that
try...after
"provides only a soft guarantee", but I guess I'm bit of a noob to handle this properly.The text was updated successfully, but these errors were encountered: