maz

maz

Using erlports and jaxon to grab youtube metadata via python -- handle_info/2 FunctionClauseError

With the genserver code I’m calling a python script. The script returns back asynchronously a large json blob to stdout.

What’s not clear to me is why there an error after the successful call to handle_info, ** (FunctionClauseError) no function clause matching in GrabAdapter.handle_info/2

Any insight into this? Is there a better way to do this than ports? I’ve noticed that if the JSON returned is ever malformed, The GenServer crashes and never comes back (“BROKEN PIPE”)

iex(2)> GrabAdapter.start_link("https://www.youtube.com/watch?v=ABuNwLP-z9o")
{:ok, #PID<0.518.0>}
Received message from port: {"id": "ABuNwLP-z9o", "uploader": "Phan Trieu", "uploader_id": "trieuphan1", "uploader_url": "http://www.youtube.com/user/trieuphan1", "channel_id": "UCG0SzK_t4-Ylf1yZq9Xmi_g", "channel_ur...
...wed ! Gaming Music | The Best of All Time | 2020", "_filename": "\ud83d\udd25 Top 50 NoCopyRightSounds _ Best of NCS _ Most viewed ! Gaming Music _ The Best of All Time _ 2020-ABuNwLP-z9o.mp4"}

title: 🔥 Top 50 NoCopyRightSounds | Best of NCS | Most viewed ! Gaming Music | The Best of All Time | 2020
iex(3)> [error] GenServer #PID<0.518.0> terminating
** (FunctionClauseError) no function clause matching in GrabAdapter.handle_info/2
    (grabber 0.1.0) lib/grab_adapter.ex:29: GrabAdapter.handle_info({#Port<0.19>, {:exit_status, 0}}, %{port: #Port<0.19>, ytchannel: "https://www.youtube.com/watch?v=ABuNwLP-z9o"})
    (stdlib 3.11) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.11) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.11) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {#Port<0.19>, {:exit_status, 0}}
State: %{port: #Port<0.19>, ytchannel: "https://www.youtube.com/watch?v=ABuNwLP-z9o"}
** (EXIT from #PID<0.515.0>) shell process exited with reason: an exception was raised:
    ** (FunctionClauseError) no function clause matching in GrabAdapter.handle_info/2
        (grabber 0.1.0) lib/grab_adapter.ex:29: GrabAdapter.handle_info({#Port<0.19>, {:exit_status, 0}}, %{port: #Port<0.19>, ytchannel: "https://www.youtube.com/watch?v=ABuNwLP-z9o"})
        (stdlib 3.11) gen_server.erl:637: :gen_server.try_dispatch/4
        (stdlib 3.11) gen_server.erl:711: :gen_server.handle_msg/6
        (stdlib 3.11) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Marked As Solved

gregvaughn

gregvaughn

The exception occurs because a message is being delivered to your GenServer that you do not handle. You need a handle_info clause that matches what @kip said. You don’t need a try/rescue

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
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 t...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement