1

I have a long-running python script script.py. Will it cause any issues if I invoke that script one-after the another through terminal:

python script.py -----first invocation

python script.py -----second invocation before the first gets over.

Since python is a interpreted language, will there be any interference between these two scripts?

Or is it safer to make a copy of the script and then run it?

3
  • I think this is too broad to answer without you showing us what is in script.py I would vote to close this personally. Commented Oct 23, 2018 at 16:46
  • The two answers on this question have quite aptly resolved my query. So I believe this is not a very broad question. I would vote to keep this open personally. Commented Oct 23, 2018 at 18:34
  • I'm glad you got an answer. It is a very broad question still though. Commented Oct 24, 2018 at 7:10

2 Answers 2

2

That depends entirely on what the script does.

In the simplest sense, the answer is no - though the two invocations run the same code, they don't inherently share any state and they can run side by side. Just like any program on your computer, ( for example, bash shell in separate terminals ), independent invocations have their own process space.

The only case your scripts might interfere with each other is if they both use shared resources. For example, if script.py created a file called /tmp/state.py then obviously the two invocations would conflict.

Sign up to request clarification or add additional context in comments.

Comments

2

There is no danger from the source code; each invocation will read the file separately, allocate its own local variables, etc. However, there may be interference if the script uses any external references, such as writing to a common file.

1 Comment

Thanks for your answer. Both yours and Dan Farrell's answer basically say the same thing. But since the other answer is more verbose, I've marked it as accepted. Thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.