0

I am using PyQt to create the gui for my application and ran into some trouble using threads for seperate processes, so started to use the multiprocessing.Process class. I was, before, using Signals and slots to communicate between the worker process and the gui, but the SignalInstance class can not be pickled and as far as I know cant be used with Process so I am having to find another way to send a progress report (percent done etc) from the worker process to update a progress bar in the gui. what is the best way of doing this?

user2145312
  • 896
  • 3
  • 10
  • 33
  • What issues did you have that you had to switch from a multi-threaded approach to a multi-process approach? – mpcabd Oct 20 '15 at 07:16
  • the process running in the worker thread was locking up the gui. i posted a question here at http://stackoverflow.com/questions/33147725/qthread-locking-up-gui-pyside/33172845?noredirect=1#comment54232881_33172845 – user2145312 Oct 20 '15 at 07:17
  • Try using [postEvent](http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent) with a custom event class. You can then watch for your events with, say, an event-filter and update your progress bar from there. – ekhumoro Oct 20 '15 at 15:55

1 Answers1

0

Please see this answer, you can share memory between processes using the multiprocessing library. Documentation here (see 16.6.1.4. Sharing state between processes).

Community
  • 1
  • 1
Alon
  • 699
  • 2
  • 9
  • 17
  • 1
    it would seem I would need to pass in a Value to the subprocess which will update it as it is working, and I would need to constantly check this value from my gui class and update the progress bar according to the changing value...wouldnt this still lock up my gui? – user2145312 Oct 20 '15 at 15:26
  • I created a 'watcher' class which runs in its own thread. this monitors the Value object and updates the gui which seems to work for me – user2145312 Oct 21 '15 at 07:19
  • It's a good question, I referred to sharing memory between processes in general. I'm pretty sure there's a good way of managing communication with GUI but I don't know what it is, you're welcome to unaccept my answer (if that's possible) or post a new one to get a more specific answer. – Alon Oct 22 '15 at 14:06