# itk python blocking pyqt gui

**URL:** https://discourse.itk.org/t/itk-python-blocking-pyqt-gui/983
**Category:** Beginner Questions
**Created:** [June 5, 2018, 7:30am UTC](https://discourse.itk.org/t/itk-python-blocking-pyqt-gui/983 "2018-06-05T07:30:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![benjaminhon](https://discourse.itk.org/user_avatar/discourse.itk.org/benjaminhon/32/83_2.png) [@benjaminhon](https://discourse.itk.org/u/benjaminhon)
#### Post date: [June 5, 2018, 7:30am UTC](https://discourse.itk.org/t/itk-python-blocking-pyqt-gui/983/1 "2018-06-05T07:30:44Z")

</div>

Hi,

I’ve been trying to run itk functions in a separate thread pool, so far printing the current thread from the function shows that it is not being run on the main thread. However, running itk functions on a separate thread still seem to block the GUI of pyqt. For, example, when using a slider to set the min max of the rescale intensity filter, causes the slider to lag (which should not be the case since its not running on the UI thread).

Does anyone have any experience with ITK and PyQt5 and able to give some examples or suggestions?

Thanks

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [June 5, 2018, 6:44pm UTC](https://discourse.itk.org/t/itk-python-blocking-pyqt-gui/983/2 "2018-06-05T18:44:52Z")

</div>

Python has a [global interpreter lock (GIL)](https://wiki.python.org/moin/GlobalInterpreterLock) so only one thread can be using the python interpreter at a time. Classically, Python does not do well with light weight threading, but frequently parallel is implemented using heavy weight processes for parallelization.

The SimpleITK Python interface has spent the effort to test and support, by default, unlocking the GIL while in ITK code, while still supporting command all backs. You can see a complete Slicer modules which uses this feature here:

> <https://github.com/SimpleITK/SlicerSimpleFilters/blob/master/SimpleFilters/SimpleFilters.py>

While ITK filter are executing the Slicer GUI is updated and maintain interactivity, as well as receiving progress reporting.

HTH,  
Brad

---

<div class="post-metadata">

### Author: ![benjaminhon](https://discourse.itk.org/user_avatar/discourse.itk.org/benjaminhon/32/83_2.png) [@benjaminhon](https://discourse.itk.org/u/benjaminhon)
#### Post date: [June 11, 2018, 8:44am UTC](https://discourse.itk.org/t/itk-python-blocking-pyqt-gui/983/3 "2018-06-11T08:44:43Z")

</div>

Ok Thanks ill check it out!
