In line x in script A, I want to start running script B, which takes 10 seconds. However, I do not want line x+1 to be executed 10 seconds after line x. Is there a way to fix this?
Script B is simply an independent series of command sent to another external device. Script A is used to monitor that device. Script B does not have any return, and code after line x in script A does not rely on script B.
Overall, I want to trigger the start of Script B and let it run independent of Script A. While script A is kept running continuously.
Thanks to the comment, I found subprocess.Popen() can do the work.
Actually, Script B can be simplified into one single function (Function B). In this case, shall I create one Python script as Script B that only calls Function B, and use subprocess.Popen() to call Script B in Script A?
Or, is there a better way to call Function B, rather than Script B, in a similar fashion as in subprocess.Popen()?
I am trying to call Function B directly because my task is very time-dependent, and half a second of delay may be significant. I have measured the delay from the line x-1 in Script A to line 1 in Script B, if I call Script B in Script A. The delay is ~450 ms. I suspect the delay is from the time for the interpreter to compile Script B and execute it, even though Script B is one or two lines long.
Thank you very much!