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

Discussion in 'Python' started by Rajat, Jan 7, 2010.

  1. Rajat

    Rajat Guest

    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.
    Rajat, Jan 7, 2010
    #1
    1. Advertising

  2. Rajat

    Jorgen Grahn Guest

    Re: How to execute a script from another script and other scriptdoes not do busy wait.

    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 .
    Jorgen Grahn, Jan 7, 2010
    #2
    1. Advertising

  3. Rajat

    Guest

    Re: How to execute a script from another script and other script doesnot do busy wait.

    On Jan 7, 9:18 am, Jorgen Grahn <> 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.
    , Jan 7, 2010
    #3
  4. Rajat

    Jorgen Grahn Guest

    Re: How to execute a script from another script and other scriptdoes not do busy wait.

    On Thu, 2010-01-07, wrote:
    > On Jan 7, 9:18 am, Jorgen Grahn <> 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 .
    Jorgen Grahn, Jan 8, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Huey

    How to make "fork/wait" to WAIT longer?

    Huey, Mar 1, 2004, in forum: C Programming
    Replies:
    1
    Views:
    1,945
    -berlin.de
    Mar 1, 2004
  2. Paul L. Du Bois

    Queue.Queue-like class without the busy-wait

    Paul L. Du Bois, Mar 24, 2005, in forum: Python
    Replies:
    29
    Views:
    1,038
    Antoon Pardon
    Apr 4, 2005
  3. black_13
    Replies:
    2
    Views:
    535
    Matt Nordhoff
    Feb 15, 2008
  4. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    543
    Jan Kaliszewski
    Jan 7, 2010
  5. Hal Vaughan
    Replies:
    0
    Views:
    578
    Hal Vaughan
    Sep 12, 2005
Loading...

Share This Page