mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 02:19:26 +01:00
auto-t: ead.py: use non_block_wait
This commit is contained in:
parent
5ebbe07fa6
commit
b705a579ad
@ -81,12 +81,8 @@ class EAD(iwd.AsyncOpAbstract):
|
||||
_adapters = None
|
||||
|
||||
def __init__(self):
|
||||
tries = 0
|
||||
while not self._bus.name_has_owner(EAD_SERVICE):
|
||||
if tries > 200:
|
||||
raise TimeoutError('IWD has failed to start')
|
||||
tries += 1
|
||||
time.sleep(0.1)
|
||||
ctx.non_block_wait(self._bus.name_has_owner, 20, EAD_SERVICE,
|
||||
exception=TimeoutError('EAD has failed to start'))
|
||||
|
||||
self._adapters = AdapterList(self)
|
||||
|
||||
@ -103,21 +99,8 @@ class EAD(iwd.AsyncOpAbstract):
|
||||
if not wait_to_appear:
|
||||
return list(self._adapters.values())
|
||||
|
||||
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 = ctx.mainloop.get_context()
|
||||
while len(self._adapters) < wait_to_appear:
|
||||
context.iteration(may_block=True)
|
||||
if self._wait_timed_out:
|
||||
raise TimeoutError('IWD has no associated devices')
|
||||
finally:
|
||||
if not self._wait_timed_out:
|
||||
GLib.source_remove(timeout)
|
||||
ctx.non_block_wait(lambda s, num : len(s._adapters) >= num, max_wait, self, wait_to_appear,
|
||||
exception=TimeoutError('EAD has no associated devices'))
|
||||
|
||||
return list(self._adapters.values())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user