mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
auto-t: ofono.py: use non_block_wait
This commit is contained in:
parent
4e3cedc901
commit
80ee406e3e
@ -9,13 +9,8 @@ class Ofono(dbus.service.Object):
|
||||
def __init__(self, namespace=ctx):
|
||||
self._bus = namespace.get_bus()
|
||||
|
||||
tries = 0
|
||||
|
||||
while not self._bus.name_has_owner('org.ofono'):
|
||||
if tries > 100:
|
||||
raise TimeoutError('Waiting for org.ofono service timed out')
|
||||
tries += 1
|
||||
time.sleep(0.1)
|
||||
ctx.non_block_wait(self._bus.name_has_owner, 10, 'org.ofono',
|
||||
exception=TimeoutError('Waiting for org.ofono service timed out'))
|
||||
|
||||
def enable_modem(self, path):
|
||||
self._modem_path = path
|
||||
@ -31,7 +26,6 @@ class Ofono(dbus.service.Object):
|
||||
self._sim_auth_up = True
|
||||
|
||||
def wait_for_sim_auth(self, max_wait = 15):
|
||||
mainloop = GLib.MainLoop()
|
||||
self._sim_auth_up = False
|
||||
|
||||
props = self._modem_iface.GetProperties()
|
||||
@ -42,18 +36,5 @@ class Ofono(dbus.service.Object):
|
||||
self._modem_iface.connect_to_signal('PropertyChanged',
|
||||
self._modem_prop_changed)
|
||||
|
||||
self._wait_timed_out = False
|
||||
def wait_timeout_cb():
|
||||
self._wait_timed_out = True
|
||||
return False
|
||||
|
||||
try:
|
||||
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
||||
context = mainloop.get_context()
|
||||
while (not self._sim_auth_up):
|
||||
context.iteration(may_block=True)
|
||||
if self._wait_timed_out:
|
||||
raise TimeoutError('waiting for SimAuthentication timed out')
|
||||
|
||||
finally:
|
||||
GLib.source_remove(timeout)
|
||||
ctx.non_block_wait(lambda s : s._sim_auth_up, max_wait, self,
|
||||
exception=TimeoutError('waiting for SimAuthetication timed out'))
|
||||
|
Loading…
Reference in New Issue
Block a user