chanzuckerberg / napari-plugin-alfa-cohort

Repo for the CZI Imaging Team's napari plugin Alfa Cohort collaboration
http://chanzuckerberg.github.io/napari-plugin-alfa-cohort
MIT License
11 stars 6 forks source link

process management in plug-ins #21

Open carsen-stringer opened 3 years ago

carsen-stringer commented 3 years ago

If I start a basic new window in pyqt and run something there it will cause the whole GUI to hang until it completes. Should plug-ins start separate python processes that run in the background or does napari have a way to handle this?

neuromusic commented 3 years ago

hey @sofroniewn or @tlambert03, can you share some insight here on how the plugin interface handles processing?

tlambert03 commented 3 years ago

napari is still a single-threaded program. So yep, if you call a long-running function in the main thread, the GUI will freeze up. We haven't yet gone so far as forcing all plugin things to happen in a separate thread (since it is very tricky to do that in a thread-safe way, without knowing what the plugin developer is attempting to do, while still giving them access to events and objects in the main gui thread). So, for now, it's up to plugin developers to handle multi-threading themselves. however, we do have some tools to try to make this easier for people, specifically, see our thread_worker decorators, described in our documentation on multithreading.