lgfor.blogg.se

Python closes after running script
Python closes after running script









Naturally Python loses that "battle" because it is not the one allowed to go interactive at that moment. That happens because the Python interpreter in background "competes" the prompt with the command-line shell as soon as it finishes executing the test.py program. Where shell was expecting input and I typed echo 'hello world' after the 10 "Hello World"'s. Sending it to the bg after running it normally in the fg gives: $ (For reference, test.py contains from time import sleepĪnd my shell looks like this: $ python3 -i test.py &Īnd I typed a after being prompted by the first >, but it isn't shown. How do I run the interactive shell "normally" after running test.py in the background? fg %4) leads to an interactive shell where my input can't be seen but is still run after pressing.

python closes after running script

, and I can't access python's interactive shell (with the variables from test.py still in the environment) afterwards.

python closes after running script python closes after running script

The job stops automatically with a ^C and shows + Stopped python3 -i test.py However, if I try to run it in the background with python3 -i test.py & Python3 -i test.py opens an interactive python shell after running test.py.











Python closes after running script