I try to use SecretStorage in 2 Python processes, but when I try to update my Gtk.Window I get this message most of the time:
RuntimeError: Unable to initialize SecretService: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Both started with multiprocessing.Process, this is working:
def get_data(self):
p1 = Process(target=P1().update_database)
p1.start()
p1.join()
p2 = Process(target=P2().update_database)
p2.start()
p2.join()
Problem is: this is blocking my Gtk Interface, Window is blocked,no other buttons are clickable.
Because of this I used a also threading.Thread
def on_get_data_button_clicked(self, widget):
thread = Thread(target=self.get_data)
thread.start()
This is also working, but I cannot see from the main window if process is still in progress.
So I added an Gtk.Spinner-Button to see the activity
def on_get_data_button_clicked(self, widget):
thread = Thread(target=self.get_data)
thread.start()
GObject.timeout_add(200, self.manage_spinner, thread)
def manage_spinner(self, thread):
if thread.is_alive():
return True
else:
self.sync_spinner.stop()
return False
Sometimes this is working, but most of the time I get this error:
RuntimeError: Unable to initialize SecretService: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
In the subscripts SecretStorage is used this way:
def get_key(self, key_name):
bus = secretstorage.dbus_init()
collection = secretstorage.get_default_collection(bus)
if collection.is_locked():
collection.unlock()
items = collection.get_all_items()
for item in items:
if item.get_label() == key_name:
return item.get_secret()
The problem occurs if GObject.timeout_add is called during the get_key() call.
And maybe it is also related to this question: How to find a key by label from secretstorage collection