Ignoring timeouts in Drakma
Hans Hübner
hans.huebner at gmail.com
Wed Jun 12 19:58:03 UTC 2013
This is not Drakma specific:
(defun try-request-from-multiple-urls (&rest urls)
(loop
(with-simple-restart (try-next "Try next URL")
(handler-case
(let ((url (first urls)))
(format t "requesting ~A~%" url)
(return (drakma:http-request url)))
(usocket:timeout-error ()
(setf urls (rest urls))
(unless urls
(format t "no more urls, returning~%")
(return))
(format t "timeout, trying next url~%")
(invoke-restart 'try-next))))))
Tune as desired. If you want to have the last timeout error percolate to
the caller, you'll want handler-bind instead.
-Hans
On Wed, Jun 12, 2013 at 9:42 PM, Patrick May <patrick.may at mac.com> wrote:
> I have a list of IP addresses to poll and want to catch the
> USOCKET:TIMEOUT-ERROR from Drakma when a machine isn't available, log a
> message, and continue on mapping over the list. Does anyone have an
> example of how to do this?
>
> Thanks,
>
> Patrick
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/drakma-devel/attachments/20130612/75cde449/attachment.html>
More information about the Drakma-devel
mailing list