-
-
Notifications
You must be signed in to change notification settings - Fork 155
Closed
Description
I have code like this:
def retry_timeout(seconds, waiting_for_if:)
raise 'waiting_for_if must be a Proc object' unless waiting_for_if.is_a? Proc
tries = 0
begin
tries += 1
Timeout.timeout(seconds) do
while waiting_for_if.call
sleep 1
end
end
rescue TimeoutError
logger.info description if description.present?
logger.info "Timeout after waiting #{seconds} seconds, Retried #{tries} times."
retry
end
end
waiting_for_if_proc = proc do
browser.goto 'some_url'
browser.network.wait_for_idle
# do many crap
sleep 100 # wait timeout happen.
endThen load it use:
begin
retry_timeout 55, wait_for_if: wait_for_if_proc
ensure
browser.quit
end It works when first time scrap, but, if timeout happen, when goto some_url again, wait_for_idle will keep block current network request, util Ferrum::TimeoutError happen, and raise error like this:
gems/ferrum-0.11/lib/ferrum/network.rb:30:in `wait_for_idle': Timed out waiting for response. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the :timeout option to a higher value might help. (Ferrum::TimeoutError)
But after remove all browser.network.wait_for_idle, all works quite well.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels