running two python script in parallel in pycharm
Asked Answered
S

4

17

I have looked at this question but I am not sure I got it correctly or not.

I have opened pycharm and one python script and its running (it's topic modeling).

Also I have another python script in which I opened in another pycharm in the same server. I also run it.

Now these two program are running in the same server, I should mention that I have not changed any configuration neither server nor pycharm.

Do you think its ok in this way? or one script technically won't run(in terms of progressing I mean it just show its running but practically wont run) until the other script finished?

Sklar answered 12/7, 2018 at 4:1 Comment(0)
A
10

First, PyCharm will create independent processes on the server, so both scripts will run. You can check it with something like htop - search for processes and verify that they're running.

Second, you don't have to open second PyCharm window to run the second script. You can run both of them from the single one. There are at least two ways: with run configurations or by spawning multiple terminal windows and running scripts from there.

Alderson answered 12/7, 2018 at 4:45 Comment(3)
Thank you so much for replying, I got GC error while I was running one python script in pycharm and one java in IntelliJ. I have 500gig ram so it was weird to me raising this error. that's why I was suspicious what is happening behind the scenceSklar
Glad I helped, GC error might be because Java can't use your whole memory, you should raise an upper boundary in Help -> Edit Custom VM Options: superuser.com/a/1141412/659142Alderson
In the run configuraiton there's a box that let's you tick allow parallel run, which will then allow you to simply click the run button multiple times and it will run in parallelGallon
U
32

Edit Configurations -> Allow parallel run. Done

enter image description here

Urnfield answered 8/11, 2019 at 10:22 Comment(2)
Can I allow parallel run by default for all configurations? Or I need to check it for each configuration (which gets pretty annoying).Schizont
N.B. For newer versions of PyCharm (e.g. 2024.X), the option is still under Edit Run Configuration, but then -> "Modify options" -> "Allow multiple instances"Why
A
10

First, PyCharm will create independent processes on the server, so both scripts will run. You can check it with something like htop - search for processes and verify that they're running.

Second, you don't have to open second PyCharm window to run the second script. You can run both of them from the single one. There are at least two ways: with run configurations or by spawning multiple terminal windows and running scripts from there.

Alderson answered 12/7, 2018 at 4:45 Comment(3)
Thank you so much for replying, I got GC error while I was running one python script in pycharm and one java in IntelliJ. I have 500gig ram so it was weird to me raising this error. that's why I was suspicious what is happening behind the scenceSklar
Glad I helped, GC error might be because Java can't use your whole memory, you should raise an upper boundary in Help -> Edit Custom VM Options: superuser.com/a/1141412/659142Alderson
In the run configuraiton there's a box that let's you tick allow parallel run, which will then allow you to simply click the run button multiple times and it will run in parallelGallon
B
8

From the Run/Debug Configurations windows you can add a Compound configuration that contains multiple configurations that will run in parallel. The Allow parallel run option for child configurations make no difference in this case.

enter image description here

Begotten answered 2/10, 2020 at 18:42 Comment(1)
This allowed me to run more than one script in parallel, but didn't allow me to run the same script twice in parallelSarto
L
3

The default behaviour was changed starting from version 2018.3. You can allow multiple runs by selecting Allow parallel run within the Edit Configurations menu.

Lubbi answered 19/10, 2019 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.