Skip to content

Instantly share code, notes, and snippets.

@chazsconi
chazsconi / controller.ex
Last active July 27, 2019 14:26
Handling long polling and trapping shutdown
def wait(conn, _params) do
Logger.info("start - #{inspect(self())}")
Logger.info("Sleeping...")
Process.flag(:trap_exit, true)
result =
receive do
{:EXIT, _caller, :shutdown} ->
Logger.info("Got shutdown")
:shutdown