lud
All is in the title, but to clarify:
It seems that if Task.yield returns {:ok, value} it means that the task result message was received, so there is no risk of receiving an unhandled message later, thus no need to call Task.await (which would give the same value anyway).
But I want to be sure.
Thank you
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Please clarify your use case? What are you doing exactly and how is
Task.yieldbetter in your scenario, compared to usingTask.async+Task.await?lud
I need to send the task result in a 2500ms timeframe. If the result is not ready yet, I have to send a dummy message, and I have another way to send the result back.
So basically
So I did a simple test in the shell and I have my answer anyway : after calling
Task.yield, no more messages from the task are coming (the monitor is also cleaned).LostKobrakai
I’ve started build a library around oban a few month ago, which does what you’re doing here, but with the persistent queue of oban. I just didn’t finish it properly at the time.
peerreynders
… provided the task has already terminated
And the documentation points this out.
lud
I looked into it but it lack docs indeed.
Here I have 3 processes :
spawnprocess (will be a supervised task that you do not have to await). This one yields from the task and return the data, but if the data is not ready, it will await it forever (I forgot to set infinity timeout on await). That is why I don not usespawn_link.The trick is that if the
yieldis succesful, we do not want to callsend_delayed_responseas we will just return the data.So your
on_task_gonecould be a good fit but I would have to use onlyTask.awaitthen ? and catch the timeout exit on my own ? I did not plan to use oban or other libraries because my problem is solved with this single block. But if you want to separate that from Omen and create a tiny lib that just redirects the task result to another destination after a special yield I’d use it.lud
Absolutely, that is why I said if Task.yield returns {:ok, value}?. Of course if
yieldreturnsnilyou have toawaitoryieldmore.But the documentation does not tell that if
yieldis successful you can forget about the task entirely, and on the other hand stresses very much about the need toawaitat all costs.peerreynders
The point is that in general a timed out yield should be accompanied by a
Task.shutdown/2.It seems a peculiar decision to use the timeout and then not terminate the task - by calling
awaityou are giving the task an additional 5000 ms. If the task still doesn’t respond the process will exit.LostKobrakai
Yeah, I created it specifically to add the functionality you have with
Taskto jobs inOban, because I don’t like the task being silently dropped if e.g. the machine goes down after your 2500ms timeframe, but before the Task itself actually finished.lud
I don’t know if it is peculiar, it is just what those who call my code expect : a response within 2500ms or a response elsewhere, later. In either case the task has to be completed.
shutdowndoes not fit in this scheme.My code above lacks the timeout for
await, which will be:infinityactually.Thank you
peerreynders
Your approach still lacks resilience as the
parentmay get thestill_runningmessage but there never is a follow up because theTaskgoes zombie or crashes after being late.I’d look into using Task.Supervisor instead.
Example: