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