# Running scripted-cli prevents QProcess from finishing

**URL:** <https://discourse.slicer.org/t/running-scripted-cli-prevents-qprocess-from-finishing/26534>\
**Category:** Development\
**Tags:** python, qt\
**Created:** [December 1, 2022, 12:16pm UTC](https://discourse.slicer.org/t/running-scripted-cli-prevents-qprocess-from-finishing/26534 "2022-12-01T12:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandus1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brandus1/32/13776_2.png) [@brandus1](https://discourse.slicer.org/u/brandus1)\
**Post date:** [December 1, 2022, 12:16pm UTC](https://discourse.slicer.org/t/running-scripted-cli-prevents-qprocess-from-finishing/26534/1 "2022-12-01T12:16:39Z")

</div>

I have a module where I periodically run an instance of a subclass of QProcess, which is basically identical to @pieper 's Process class in [SlicerParallelProcessing](https://github.com/pieper/SlicerParallelProcessing/blob/master/Processes/Processes.py).

I use this class to run a python script that polls an API in a server. When the process finishes, it gets destroyed and another one is called after 2 seconds (using a QTimer).

Everything works fine until I call a scripted cli module at some point. Basically, as soon as a scripted-cli module runs, the QProcess hangs - it does not emit the finished() signal anymore. The script runs fine without errors, I checked the standard output and no problem there. It just doesn’t finish.

It does not have anything to do with what the scripted-cli module does: it happens with my module or even the standard cli module produces by the Extension Wizard.

Note: the problem does not happen if your run a c++ cli module

I am not very familiar with the underlyings of PythonSlicer or QTClI, but I think it might have something to do with them.

Any idea?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 3, 2022, 3:45pm UTC](https://discourse.slicer.org/t/running-scripted-cli-prevents-qprocess-from-finishing/26534/2 "2022-12-03T15:45:57Z")

</div>

CLI modules are run in independent threads, while python code runs in the main thread, so that may be the difference. If you are still having trouble try to create a minimal example that others can test with and help you debug.
