# LoadState in parallel

**URL:** https://discourse.paraview.org/t/loadstate-in-parallel/12932
**Category:** ParaView Support
**Created:** [September 26, 2023, 9:02am UTC](https://discourse.paraview.org/t/loadstate-in-parallel/12932 "2023-09-26T09:02:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![madmoonman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@madmoonman](https://discourse.paraview.org/u/madmoonman)
#### Post date: [September 26, 2023, 9:02am UTC](https://discourse.paraview.org/t/loadstate-in-parallel/12932/1 "2023-09-26T09:02:48Z")

</div>

Hello,  
I am looking to parallelize a script that loads multiple state files with different simulation results: [Replace a variable when LoadState()](https://discourse.paraview.org/t/replace-a-variable-when-loadstate/12921)

What is the correct approach to open multiple sessions in pvpython? I was looking into servermanager.Connect() and servermanager.LoadState(), but the ladder lacks arguments provided by paraview.simple.LoadState() which are statefile and data\_directory.

Thank you.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 26, 2023, 9:05am UTC](https://discourse.paraview.org/t/loadstate-in-parallel/12932/2 "2023-09-26T09:05:10Z")

</div>

Hi @madmoonman

The best way is to use pvbatch

[https://docs.paraview.org/en/latest/Tutorials/ClassroomTutorials/pythonAndBatchPvpythonAndPvbatch.html](https://docs.paraview.org/en/latest/Tutorials/ClassroomTutorials/pythonAndBatchPvpythonAndPvbatch.html)

---

<div class="post-metadata">

### Author: ![madmoonman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@madmoonman](https://discourse.paraview.org/u/madmoonman)
#### Post date: [October 6, 2023, 1:14pm UTC](https://discourse.paraview.org/t/loadstate-in-parallel/12932/3 "2023-10-06T13:14:51Z")

</div>

Just wanted to report back here. Thanks for suggesting pvbatch, Mathieu.

I went on another path, building a main function that triggers subprocesses via the python multiprocessing package and then within each subprocess I run a function that imports paraview.simple on its own. This gives me parallel execution without changing any of my code. Sorry, I was a bit too lazy to look into pvbatch 🙂
