IMatch.processRun without timeout?

Started by gangenen, September 08, 2017, 12:17:40 AM

Previous topic - Next topic

gangenen

Is it possible to use IMatch.processRun without a timeout, i.e. that the application called stays open until I close it and the script does not continue until the application is closed?

I am thinking about an import workflow where I would call GeoSetter and then would like to continue the automated flow when I am done in Geosetter and have closed it.

This seems to work but has a (long) timeout set:

                        IMatch.processRun({
                        'executable' : '\"' + GeoSetterPath + '\"',
                        'parameters' : GeosetterParameter,
                        'showwindow' : true,
                        'timeout' : '3600'
                       
                        }).then(function(response) {
                        // showAnimation(false);
                            console.log('Calling Geosetter was successful');
                        },


/Georg

Mario

Blocking a JavaScript for a long time is not a good idea.
The request is blocked for the time while the process runs, the web server holds the connection open and you may run into a web server timeout if you try to keep it running for more than, say, 120 seconds. Also depends on how IMWS is configured. This is not designed to run processes which take literally hours to complete. The maximum timeout is 1000 seconds.

If you need GeoSetter, work with in regulary. Let it updates your images and iMatch will pick up the changes automatically. For all else, the Map Panel in IMatch will do the trick.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

There is a rather elegant solution for this, though.

You can just start GeoSetter using IMatch.shellExecute.
Then write a function which uses processRun to run the command line tool tasklist and grab the output.
tasklist returns the names of all running processes. You can also use it with a filter, like

tasklist /FI "IMAGENAME eq IMatch2017x64.exe"

to check if a specific task is running.

Just search the output returned by tasklist for "GeoSetter.exe" (or whatever the process name is). If the function does not find it, it is not running anymore. Bingo.

The Process sample app shows how to do this with the dir and systeminfo examples.

If you call this function from your app every 5 seconds or so (using windows.timeOut) your app will know when you have exited GeoSetter and then do whatever needs doing.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

gangenen

Thanks. I was not thinking about any timeout from the web-server's side.

I will try the process monitoring suggestion.

/Georg