Thursday, July 31, 2014

pyAstroStack: Multithreading vision and status

The GUI of pyAstroStack works reasonably well (for such a limited gui that is...) in version 0.4, but my original plan was a little different. Now that I have time to code again after summer, I'm finally getting my vision to work.

Here's a screenshot of current 0.5dev


I want the list of files to be more interactive. First column shows the file path, second is frame type, but the rest are what I'm working on. Decoded means reading the RAW file and decoding it to FITS. Numbers 0, 1 and 2 are place holders for "Not started", "Working..." and "Done". I'm not sure if I want some kind of icons or rolling animations there, but for now only the place holders.

The moment you select some images and click OK, the program starts decoding them on background. Gui will be responsive all this time and you can select more files while it's working. You can also set parameters for full process while it's working on background.


My problem was that even I had multithreading set up, the gui stayed unresponsive and didn't update. I searched and read lots of tutorials and stackoverflow questions, but no help. Finally I found it! I had

threadpool = QThreadPool()

but instead it should have threadpools parent as an argument. I changed it into

threadpool = QThreadPool(self)

and everything started working. This might be obvious for more experienced PyQt programmers, so I can understand why no tutorial emphasized the importance of it. Maybe now I remember that all QWidgets require the parent as an argument.

Decoding works with 5 simultaneous threads, but with 10 there are random errors. I wonder if the threads are trying to use same files at the same time. If so, it has to be fixed. The rest of the program is currently broken (on 0.5dev, on 0.4.1 it works of course) because I had to do significant changes to the frame handling to get multithreading to work.