Skip to content

Commit

Permalink
Fix Crawly.Utils.list_spiders/0 (#300)
Browse files Browse the repository at this point in the history
The list_spiders function is a bit tricky, it was using __info__ method,
that as I see does not work in quite a few cases. Even worse it was
just hanging when :shell_defaults.__info__ was called.

I decided to change the function to use .module_info instead, and added
some debug loggings
  • Loading branch information
oltarasenko authored Jul 4, 2024
1 parent 2ca7370 commit 0fd9aa6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/crawly/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ defmodule Crawly.Utils do
fn mod, acc ->
try do
behaviors =
Keyword.take(mod.__info__(:attributes), [:behaviour])
Keyword.take(mod.module_info(:attributes), [:behaviour])
|> Keyword.values()
|> List.flatten()

Expand All @@ -177,8 +177,11 @@ defmodule Crawly.Utils do
acc
end
rescue
_error ->
# Just ignore the case, as probably the given module is not a Spider
error ->
Logger.debug(
"Could not classify module #{mod} as spider: #{inspect(error)}"
)

acc
end
end
Expand Down

0 comments on commit 0fd9aa6

Please sign in to comment.