mirror of https://github.com/tuhiproject/tuhi.git
kete: move the mainloop thread into the manager
The manager handles the mainloop, so it's easier if it handles the attached thread too.pull/61/head
parent
8affec2002
commit
5757bcfab1
|
@ -226,7 +226,6 @@ class TuhiKeteDevice(_DBusObject):
|
||||||
if d.address == self.address:
|
if d.address == self.address:
|
||||||
self.is_pairing = False
|
self.is_pairing = False
|
||||||
logger.info(f'{self}: Pairing successful')
|
logger.info(f'{self}: Pairing successful')
|
||||||
self.manager.quit()
|
|
||||||
|
|
||||||
|
|
||||||
class TuhiKeteManager(_DBusObject):
|
class TuhiKeteManager(_DBusObject):
|
||||||
|
@ -258,6 +257,10 @@ class TuhiKeteManager(_DBusObject):
|
||||||
device = TuhiKeteDevice(self, objpath)
|
device = TuhiKeteDevice(self, objpath)
|
||||||
self._devices[device.address] = device
|
self._devices[device.address] = device
|
||||||
|
|
||||||
|
self._glib_thread = threading.Thread(target=self.run)
|
||||||
|
self._glib_thread.daemon = True
|
||||||
|
self._glib_thread.start()
|
||||||
|
|
||||||
@GObject.Property
|
@GObject.Property
|
||||||
def devices(self):
|
def devices(self):
|
||||||
return [v for k, v in self._devices.items()]
|
return [v for k, v in self._devices.items()]
|
||||||
|
@ -955,13 +958,7 @@ class TuhiKeteShellWorker(Worker):
|
||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
super(TuhiKeteShellWorker, self).__init__(manager)
|
super(TuhiKeteShellWorker, self).__init__(manager)
|
||||||
|
|
||||||
def start_mainloop(self):
|
|
||||||
self.manager.run()
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._glib_thread = threading.Thread(target=self.start_mainloop)
|
|
||||||
self._glib_thread.daemon = True
|
|
||||||
self._glib_thread.start()
|
|
||||||
|
|
||||||
self.run()
|
self.run()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue