0

I will in python start a application and wait until the application is READY (therefore I will NOT wait until the application is finished). It is a general question by me, therefore is it irrelevant from which application we speak here. In my case is it a "big" application" (by dSPACE ==> AurelionManager ==> Product link to dSPACE-Homepage) which need ca. 10 seconds or longer until the "loading status" of the application have reached 100% and the application is "usable" (by GUI or e.g. automatisized over python by using of web-services)

Therefore I need, like here described... Stackoverflow: whats-the-difference-between-subprocess-popen-and-call-how-can-i-use ...e.g. ...

Popen('notepad.exe')

...so that I start the application by python and I have in general a none blocking behavior, but after this I should have any "construct"/code which wait so long until the loading work (of the application) is finished (therefore the application is from OS point of view complete loaded and therefore the application is "ready") before I go on with "other work" in the python-world which try to communicate (in my case by web-services) with the even (by Popen) started application

Have anybody here a idea how I can reach this? Many thanks already now for the help :-)

Fonso
  • 31
  • 3
  • Usually, big applications aren't loaded in memory completely but on demand, similar to a memory mapped file plus separate dynamic libraries and data files. Therefore it is complicated to find a definition of "loaded" or "ready" which can be measured without knowing the application in detail. – Michael Butscher Jun 13 '23 at 15:54

1 Answers1

0

I did contact the dSPACE-guys, in my case is the solution for waiting until the application is really simple ("BruceForce")

Try in a loop to send periodic a web-request (which try to "read" anything from the application) so long this produce a exception (exeption is of course catched of course) because the application is NOT "ready" go on with the loop. In other case (web-request work because application is "ready") break the loop (then can you send any web-request to the application)

I think that is at each application the solution (pseudocode):

import subprocess
import time

# Start your application (non-blocking):
subprocess.Popen('YourApplication.exe')

TIME_OUT = 5

# Now wait until application is ready or until timout happen:
timeout_time = time.time() + TIME_OUT 
while True:
    try:
        <Try over the automation-interface to communicate with the application>
        # This is only reached at success (no exception above):
        break
    except:
        pass
    # At timeout create exception:
    if time.time() > timeout_time:
        raise Exception("Timeout")

# When this here is reached so is the application ready:
<communicate with the automation-interface with the application>
<communicate with the automation-interface with the application>
...

    
Fonso
  • 31
  • 3