Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to execute a script from another script and other script does notdo busy wait.

Reply
Thread Tools

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

 
 
Rajat
Guest
Posts: n/a
 
      01-07-2010
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.
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      01-07-2010
On Thu, 2010-01-07, Rajat wrote:
> 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

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
 
danmcleran@yahoo.com
Guest
Posts: n/a
 
      01-07-2010
On Jan 7, 9:18*am, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
> On Thu, 2010-01-07, Rajat wrote:
> > 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
>
> --
> * // Jorgen Grahn <grahn@ *Oo *o. * . *.
> \X/ * * snipabacken.se> * O *o * .


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

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

See subprocess docs.

 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      01-08-2010
On Thu, 2010-01-07, wrote:
> On Jan 7, 9:18*am, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
>> On Thu, 2010-01-07, Rajat wrote:
>> > 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.


....

> 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

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
'Busy Signals' from other then the called number being busy Bob Alan VOIP 1 09-28-2005 06:21 PM
SOLVED: "Text File Busy" And Other Frustrating NFS/Perl Errors Hal Vaughan Perl Misc 0 09-12-2005 07:36 PM
OT:Busy Busy Doom MCSE 36 07-08-2004 04:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57