How to create module based Tasks


Im trying reproduce the example of module-based task like the example

in my try

What is wrong ?


Can you show your supervisor as well?


i m not using module based Supervisor


Sou you are just doing elixir yourscript?

Then your script ends even before the supervisor has fully started.

Or what exactly is your problem?


ow…excuse-me i forgive to explain the error !
I got this error in shell:

** (UndefinedFunctionError) function Task.__using__/1 is undefined or private
(elixir) Task.__using__([])
module-task.exs:3: (module)
module-task.exs:1: (file)


Probably your elixir is to old.

I checked branches and Task.__using__/1 only exists in 1.5 branch.


the version is 1.4.2


As you can see, Task.__using__/1 does not exist in v1.4.2, so if you want to use it, you need to update.

Also you can take a look at the documentation of 1.4.2, the example there does not mention any use of use :wink:


i update to 1.5.2 like a doc i m read
But now i got other error:

** (UndefinedFunctionError) function Supervisor.start_link/1 is undefined or private. Did you mean one of:

  * start_link/2
  * start_link/3

but It is exact like the doc…


Supervisor.start_link/1 not exists…

This doc like wrong…


The docs are wrong.

number = 5
Supervisor.start_link([{TaskModule, number}], strategy: :one_for_one)

Since your module takes a number and adds 2 to it, we’re passing in a number (5) as the argument. You can pass in whatever you like.

See also:


thank you !
this forum is observed by core team ?
We can alert about this.
Is a trouble for newbies


It is (mostly) but it is still good to submit an issue ticket on github. :slight_smile:
Or better yet, a PR! ^.^