Skip to content

Commit f3f1d4a

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 f3f1d4a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/crawly/utils.ex

+4-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,9 @@ 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("Could not classify module #{mod} as spider: #{inspect(error)}")
182+
182183
acc
183184
end
184185
end

0 commit comments

Comments
 (0)