Skip to content

Commit cca3e17

Browse files
committed
Explain how await() should not be used with an OTP behaviour
1 parent ecabce6 commit cca3e17

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/elixir/lib/task.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ defmodule Task do
307307
This function can only be called once for any given task. If you want
308308
to be able to check multiple times if a long-running task has finished
309309
its computation, use `yield/2` instead.
310+
311+
## Compatibility with OTP behaviours
312+
313+
It is not recommended to `await` a long-running task inside an OTP
314+
behaviour such as `GenServer`. Instead, you should match on the message
315+
coming from a task inside your `handle_info` callback.
310316
"""
311317
@spec await(t, timeout) :: term | no_return
312318
def await(task, timeout \\ 5000)

0 commit comments

Comments
 (0)