Skip to content

Commit bdb7bc7

Browse files
committed
Fix Crawly.Utils.list_spiders/0
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
1 parent 2ca7370 commit bdb7bc7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/crawly/utils.ex

+6-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ defmodule Crawly.Utils do
162162
fn mod, acc ->
163163
try do
164164
behaviors =
165-
Keyword.take(mod.__info__(:attributes), [:behaviour])
165+
Keyword.take(mod.module_info(:attributes), [:behaviour])
166166
|> Keyword.values()
167167
|> List.flatten()
168168

@@ -177,8 +177,11 @@ defmodule Crawly.Utils do
177177
acc
178178
end
179179
rescue
180-
_error ->
181-
# Just ignore the case, as probably the given module is not a Spider
180+
error ->
181+
Logger.debug(
182+
"Could not classify module #{mod} as spider: #{inspect(error)}"
183+
)
184+
182185
acc
183186
end
184187
end

0 commit comments

Comments
 (0)