How to execute a script from another script and other script does notdo busy wait.

R

Rajat

I want to run a python script( aka script2) from another python script
(aka script1). While script1 executes script2 it waits for script2 to
complete and in doing so it also does some other useful work.(does not
do a busy wait).

My intention is to update a third party through script1 that script2
is going to take longer.

Please suggest how should I go about implementing it.

I'm currently executing it as:

import main from script2
ret_code = main()
return ret_code

which surely is not going to achieve me what I intend.


Thanks,
Rajat.
 
J

Jorgen Grahn

I want to run a python script( aka script2) from another python script
(aka script1). While script1 executes script2 it waits for script2 to
complete and in doing so it also does some other useful work.(does not
do a busy wait).

My intention is to update a third party through script1 that script2
is going to take longer.

I do not understand that sentence.
What are you trying to do, more exactly? The best solution can be
threads, os.popen, os.system or something different -- depending on
the details of what you want to do.
Please suggest how should I go about implementing it.

I'm currently executing it as:

import main from script2
ret_code = main()
return ret_code

which surely is not going to achieve me what I intend.


Thanks,
Rajat.

/Jorgen
 
D

danmcleran

I do not understand that sentence.
What are you trying to do, more exactly?  The best solution can be
threads, os.popen, os.system or something different -- depending on
the details of what you want to do.






/Jorgen

I personally use subprocess. Once you launch via subprocess you can
wait or not.

p = subprocess.Popen(...)
p.wait() #or not.

See subprocess docs.
 
J

Jorgen Grahn

....

I personally use subprocess. Once you launch via subprocess you can
wait or not.

p = subprocess.Popen(...)
p.wait() #or not.

See subprocess docs.

Yes, that was included in "or something different" above. I have never
used it myself, since I've needed to be compatible with Python < 2.4.

Still, we need to know what he tries to do.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top