I followed this guide for multithreading in pyside with QThreadPool. I have a few instances of workers for jobs that will, and also could potentially take a long time. For example:
def load_bucket_dir(self):
worker = Worker(UIFunctions.update_bucket_tree, self)
worker.signals.finished.connect(lambda: widgets.browse_s3_dir.setEnabled(True))
self.threadpool.start(worker)
This function will fetch a user's specified s3 bucket and display the contents in a QTreeWidget. This uses OIDC authentication, which takes a few seconds to complete.
Example 2:
def load_bucket_preview(self):
if self.ui.local_dir.text() and self.ui.s3_dir.text():
worker = Worker(UIFunctions.update_bucket_preview, self)
self.threadpool.start(worker)
This function displays a preview of files to be uploaded to their s3 bucket depending on the selected files. The speed of this function depends on how many files are selected.
My issue is that whenever a worker is started, I get warnings like these:
QBasicTimer::stop: Failed. Possibly trying to stop from a different thread
QBasicTimer::stop: Failed. Possibly trying to stop from a different thread
QBasicTimer::start: Timers cannot be started from another thread
QObject::killTimer: Timers cannot be stopped from another thread
And then eventually I get a segmentation fault (either immediately or after some time). The guide I linked didn't specify how to run multiple workers, so I'm assuming I've done something incorrectly.