Choose Language Hide Translation Bar
Highlighted
Brandon
Level II

Http Background Request

Hi,

 

I am trying to use the HTTP Request function but it often can take some time to return the data I am requesting.  I am wondering if it is possible to send an HTTP request in a background and then continue on with the script.  Later when the data is needed I could check to see if it is returned and then either continue on or wait for it to be returned.  If this is possible I could parallelized multiple request that are needed instead of running them in serial.  

 

Thanks for your help

2 REPLIES 2
Highlighted
burakbagdatli
Level III

Re: Http Background Request

I have never tried this myself but JSL has a "Schedule()" command that can create an independent thread. However, you cannot create more than 1 thread. So, in your case the HTTP request can be sent to that thread but they will still run in series.

https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/scheduling-actions.shtml

Update: See Craig Hales' reply below. Apparently, commands scheduled this way only run when JMP is idle and the commands still run in the foreground. I didn't have a good example to prototype something before I replied. Sorry if I caused any confusion.

 

 

Another approach could be that you run multiple instances of JMP by using the "Run Program()" command. I believe these can be made to run without waiting for the external program to finish executing. I tried this before but never for multi-threading. You just gave me an idea that I want to try now!

https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/run-external-programs.shtml

https://www.jmp.com/support/help/en/15.2/index.shtml#page/jmp/utility-functions.shtml#ww4547957

Update2: Also see Craig Hales' blog post on this idea. Thanks a lot Craig! https://community.jmp.com/t5/Uncharted/Can-JMP-run-JMP/ba-p/283748

 

I don't think either of these solutions are ideal but they probably will improve your script's run time. The first one is easier to implement, the second will require some rearchitecting of your code and you have to deal with starting and quitting JMP.

What we see of the real world is not the unvarnished real world but a model of the real world, constructed so it is useful for dealing with the real world. —Richard Dawkins
Highlighted
Craige_Hales
Staff (Retired)

Re: Http Background Request

Can JMP run JMP? 

 

Schedule only runs in the foreground, when JMP is idle (or wait() is called from a running script.)

Craige
Article Labels