[PyQt] Multi-process QSettings and PyQt 5

Damon Lynch damonlynch at gmail.com
Thu Apr 23 17:46:22 BST 2015


Hi everyone,

I have developed some code to use QSettings where it's easy to update 
values like prefs.value = new_value, with the values being grouped so 
that they're human readable too (GPL3+):

http://bazaar.launchpad.net/~dlynch3/rapid/zeromq_pyqt/view/head:/rapid/preferences.py#L136

I'm sure I'm far from the first person to do something very similar to 
this. I'm still new to Qt so hopefully it's okay.

I read this in the QT5 docs: "QSettings can safely be used from 
different processes (which can be different instances of your 
application running at the same time or different applications 
altogether) to read and write to the same system locations. It uses 
advisory file locking and a smart merging algorithm to ensure data 
integrity. Note that sync() imports changes made by other processes (in 
addition to writing the changes from this QSettings)."

Does the file locking and syncing work robustly using PyQt 5? Are there 
any gotchas I should be aware of? In my case I'd like it that my 
single-instance only application will have a couple of processes that 
read and write the settings. The main GUI process will do the majority 
of reading and writing, and a secondary process will read various values 
and write two of them. Hopefully that's a relatively easy use case and 
there is nothing to worry about.

Best,
Damon

-- 

http://www.damonlynch.net



More information about the PyQt mailing list