🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to code such that the program does not wait for execution of a command?

User: "Rachit Semalty"
Altair Community Member
Updated by Rachit Semalty

Hi. I am trying a code:

      exec python_path python_file.py;

      puts 1;

So the problem is that 1 is not printed till the execution of the python file is completed. I want the code to proceed even if the python file is still running.

Does anyone know how to solve the problem?

Regards,

Rachit

Find more posts tagged with

Sort by:
1 - 4 of 41
    User: "Nagahashi Kouta"
    Altair Community Member
    Updated by Nagahashi Kouta

    Hi, Rachit Semalty

    The following commands may help you

    package require Thread
    set thread_id [thread::create {exec python_path python_file.py}]

    puts 1

    User: "Ben Buchanan"
    Altair Employee
    Accepted Answer
    Updated by Ben Buchanan

    I think what you are looking for is just to add an & to the end. Like this:

    exec python_path python_file.py &;

    User: "Rachit Semalty"
    Altair Community Member
    OP
    Updated by Rachit Semalty

    Hi, Rachit Semalty

    The following commands may help you

    package require Thread
    set thread_id [thread::create {exec python_path python_file.py}]

    puts 1

    Thanks, Nagahashi for your reply. It was helpful. I was hoping to do it without creating a thread but it is also a good solution.

     

    Regards,

    Rachit

    User: "Rachit Semalty"
    Altair Community Member
    OP
    Updated by Rachit Semalty

    I think what you are looking for is just to add an & to the end. Like this:

    exec python_path python_file.py &;

    Hi Ben. Thanks for your reply. Your solution worked for me.

     

    Regards,

    Rachit