Tano

Tano

Currently I am reading Elixir In Action and it is mentioned there for Task.async that the return value of the executed lambda is sent back as a message to the starter process. I am a bit confused here or maybe missed some important part of the text, please correct me if I am wrong: it means that even if i dont care for the return value of the lambda i must have something like handle_info to catch the message that is send back or ? Because if i dont handle the message it will just stay in the mail box forever, thanks guys

Showing Posts 1 to 4

NobbZ

NobbZ

Yes. Exactly.

I’m not aware of a Task like thing that can be run solely for its side effects. But exactly the current behaviour of sending back “unwanted” messages makes it break applications, or at least creates a lot of confusing log messages.

@Fl4m3Ph03n1x created a lot of threads to trace down those messages, and I’m not even sure if they ever found the actual source of the stray messages.

bugant

bugant

Yes, it’s quite clear in the doc I’d say. See https://hexdocs.pm/elixir/Task.html:

Tasks spawned with async can be awaited on by their caller process (and only their caller) as shown in the example above. They are implemented by spawning a process that sends a message to the caller once the given computation is performed.

And, so Task.await is used to read the message sent by the task.

jwarlander

jwarlander

The documentation also suggests several other ways to run tasks, @Tano, if you don’t want this behavior, eg. Task.start_link/1, Task.start/1, or starting tasks under a Task.Supervisor.

Fl4m3Ph03n1x

Fl4m3Ph03n1x

Yes, I found the processes sending the messages, but the methodology we used is not fit for production, unless you don’t mind killing a machine with all the logging or slowing it down considerably.

There are many ways of finding out which process is receiving an unhandled message, but there is no straight way. I have compiled a list of all the relevant posts I created regarding this topic for your convenience, should you ever venture this far into message passing:

Still, if you follow the recommendations for Task.async and Task.await, you will (hopefully) never need this information, unless you are using a 3rd party library that doesn’t follow the conventions (as was our case).

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New
AstonJ
This might be a bit disturbing for some but it’s happening - computers running on living human neurons. They’ve made them smart enough t...
New

Other Trending Topics Top

brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews