Polling break for loop

Friday, 13 August 2021 · 4 messages · last reply 15 Aug 2021
AL
Adam Law13 Aug 2021 12:24 #
If polling a url n times and breaking if response is 'completed', is the best to approach to use try catch and error() to get around immutability? I need the full response on complete so I redo the last http get. It is not a biggie requesting twice. Adam
Quoted text · 53 lines
On Fri., 13 Aug. 2021, 6:00 pm , <basex-talk-request at mailman.uni-konstanz.de> wrote: > Send BaseX-Talk mailing list submissions to > basex-talk at mailman.uni-konstanz.de > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > or, via email, send a message with subject or body 'help' to > basex-talk-request at mailman.uni-konstanz.de > > You can reach the person managing the list at > basex-talk-owner at mailman.uni-konstanz.de > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of BaseX-Talk digest..." > > > Today's Topics: > > 1. XProc? (Jonathan Robie) > 2. Re: XProc? (Martin Honnen) > 3. Pretty-print the -V optimized query? See what indexes are > used? (Jonathan Robie) > 4. Re: XProc? (Imsieke, Gerrit, le-tex) > 5. org.basex.core.BaseXException with no error message > (Matthew Dziuban) > 6. Re: org.basex.core.BaseXException with no error message > (Christian Gr?n) > 7. Re: Pretty-print the -V optimized query? See what indexes are > used? (Christian Gr?n) > 8. Can XQuery return unique values present across multiple > databases? (Tamara Marnell) > 9. Re: Can XQuery return unique values present across multiple > databases? (Martin Honnen) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 12 Aug 2021 07:58:04 -0400 > From: Jonathan Robie <jonathan.robie at gmail.com> > To: BaseX <basex-talk at mailman.uni-konstanz.de> > Subject: [basex-talk] XProc? > Message-ID: > < > CAOkFc+vMLcdXFUZBUvZZVLF8Wc3nKSLASpPKFWV_WPh7hRnEFw at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > What hooks does BaseX provide for XProc? Where can I find examples of > BaseX use in an XProc pipeline? > > Jonathan >
CG
Christian Grün13 Aug 2021 12:29 #
Quoted text · Adam Law · 1 line
> If polling a url n times and breaking if response is 'completed', is the best to approach to use try catch and error() to get around immutability? I need the full response on complete so I redo the last http get. It is not a biggie requesting twice. Adam
The hof:until function may help you [1]. Don’t hesitate to supply us with a minimized code snippet. In general, it’s almost always a good advice not to use try/catch unless you need to catch real errors. [1] https://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:until
AL
Adam Law15 Aug 2021 12:11 #
Hi Christian - many thanks for the pointer. hof:until works well and without a double http:send-request.
let $pollingResult := hof:until(function($result)
{$result?3//status/text()= 'done'},function ($input){[$input?1 +
1,prof:sleep(5000),http:send-request($requestPolling)]},
[1,0,http:send-request($requestPolling)])
Quoted text · Christian Grün · 15 lines
On Fri, Aug 13, 2021 at 6:29 PM Christian Grün <christian.gruen at gmail.com> wrote: > > If polling a url n times and breaking if response is 'completed', is the > best to approach to use try catch and error() to get around immutability? > I need the full response on complete so I redo the last http get. It is not > a biggie requesting twice. Adam > > The hof:until function may help you [1]. Don’t hesitate to supply us > with a minimized code snippet. > > In general, it’s almost always a good advice not to use try/catch > unless you need to catch real errors. > > [1] https://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:until >
AL
Adam Law15 Aug 2021 12:16 #
Slight improvement
let $polling := hof:until(function($result) {$result?3//status/text()=
'done' or $result?1 > 10},function ($input){[$input?1 +
1,prof:sleep(5000),http:send-request($requestPolling)]},
[1,0,http:send-request($requestPolling)])

⚡Generated with XQuery