darkmarmot

darkmarmot

How to kill a Task in Task.Supervisor.async_stream_nolink?

I’m running batches of short-lived fire and forget tasks (I sometimes receive feedback from them).
I can kill the tasks from within themselves… but was hoping to use the supervisor to kill long-running
tasks for me?

I’ve tried variants of the commented options, but have yet to find a way to get them to actually timeout and die . :frowning:

Am I missing some basic setting or concept here?

def work(some_values) do
   Task.Supervisor.async_stream_nolink(
      MyApp.TaskSupervisor,
              some_values,
              fn v -> do_something(v) end,
              ordered: false,
       #      timeout: 50
       #      shutdown: 50,
       #      on_timeout: :kill_task
      )
end

Thanks,
Scott

Marked As Solved

darkmarmot

darkmarmot

It turned out that an underlying library was trapping exits on spawned processes. So – these processes did end – but produced orphaned processes that made it look non-functional :frowning:

Also Liked

OvermindDL1

OvermindDL1

What library was this and what purpose was that for I’m curious?

darkmarmot

darkmarmot

So, it was an odd combo.

I’m working with :luerl – and in particular the :luerl_sandbox module which lets you limit the number of reductions used by a process running Lua code.

I had inadvertently been testing without passing in the reductions limit, which defaults to infinite reductions. But I suspect that if you do that it was trapping the exit? (I’m not yet up on Erlang :frowning:)

When I switched to “normal” :luerl it seemed to work ok. Again, this is more theory than understanding…

OvermindDL1

OvermindDL1

luerl_sandbox sounds quite useful, right now I run user lua code in a new process and if it does not complete within 5 seconds then I kill it and tell the user their script took too long. I’d love a way to suspend, serialize it out, back in, and resume it though!

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement