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!

darkmarmot

darkmarmot

Ohhh that’s a really cool idea! I’ll bring that up on the Luerl Slack if you like!

Another feature I’d appreciate is having it return the reduction count that was used by a script – so it would be easy to see how heavily your script is taxing the cpu.

If you want, check out https://hex.pm/packages/sandbox. It’s my attempt to wrap :luerl_sandbox (still very much in progress though).

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement