mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-20 04:19:25 +01:00
auto-t: fix wait_for_object_condition
After the re-write this was broken and not noticed until recently. The issue appeared to be that the GLib timeout callback retained no context of local variables. Previously _wait_timed_out was set as a class variable, but this was removed so multiple IWD instances could work. Without _wait_timed_out being a class variable the GLib timeout setting it had no effect on the wait loop. To fix this we can set _wait_timed_out on the object being passed in. This is preserved in the GLib timeout callback and setting it gets honored in the wait loop.
This commit is contained in:
parent
944e0b5e23
commit
5e631b4e38
@ -1009,9 +1009,10 @@ class IWD(AsyncOpAbstract):
|
||||
|
||||
@staticmethod
|
||||
def _wait_for_object_condition(obj, condition_str, max_wait = 50):
|
||||
_wait_timed_out = False
|
||||
obj._wait_timed_out = False
|
||||
|
||||
def wait_timeout_cb():
|
||||
_wait_timed_out = True
|
||||
obj._wait_timed_out = True
|
||||
return False
|
||||
|
||||
try:
|
||||
@ -1019,12 +1020,12 @@ class IWD(AsyncOpAbstract):
|
||||
context = ctx.mainloop.get_context()
|
||||
while not eval(condition_str):
|
||||
context.iteration(may_block=True)
|
||||
if _wait_timed_out and ctx.args.gdb == None:
|
||||
if obj._wait_timed_out and ctx.args.gdb == None:
|
||||
raise TimeoutError('[' + condition_str + ']'\
|
||||
' condition was not met in '\
|
||||
+ str(max_wait) + ' sec')
|
||||
finally:
|
||||
if not _wait_timed_out:
|
||||
if not obj._wait_timed_out:
|
||||
GLib.source_remove(timeout)
|
||||
|
||||
def wait_for_object_condition(self, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user