mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-20 19:12:33 +01:00
auto-t: fix wait_for_object_condition to work with any object
After recent changes fixing wait_for_object_condition it was accidentally made to only work with classes, not other types of objects. Instead create a minimal class to hold _wait_timed_out so it doesnt rely on 'obj' holding the boolean.
This commit is contained in:
parent
c026337792
commit
4b07280319
@ -1009,23 +1009,26 @@ class IWD(AsyncOpAbstract):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _wait_for_object_condition(obj, condition_str, max_wait = 50):
|
def _wait_for_object_condition(obj, condition_str, max_wait = 50):
|
||||||
obj._wait_timed_out = False
|
class TimeoutData:
|
||||||
|
_wait_timed_out = False
|
||||||
|
|
||||||
def wait_timeout_cb():
|
data = TimeoutData()
|
||||||
obj._wait_timed_out = True
|
|
||||||
|
def wait_timeout_cb(data):
|
||||||
|
data._wait_timed_out = True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb, data)
|
||||||
context = ctx.mainloop.get_context()
|
context = ctx.mainloop.get_context()
|
||||||
while not eval(condition_str):
|
while not eval(condition_str):
|
||||||
context.iteration(may_block=True)
|
context.iteration(may_block=True)
|
||||||
if obj._wait_timed_out and ctx.args.gdb == None:
|
if data._wait_timed_out and ctx.args.gdb == None:
|
||||||
raise TimeoutError('[' + condition_str + ']'\
|
raise TimeoutError('[' + condition_str + ']'\
|
||||||
' condition was not met in '\
|
' condition was not met in '\
|
||||||
+ str(max_wait) + ' sec')
|
+ str(max_wait) + ' sec')
|
||||||
finally:
|
finally:
|
||||||
if not obj._wait_timed_out:
|
if not data._wait_timed_out:
|
||||||
GLib.source_remove(timeout)
|
GLib.source_remove(timeout)
|
||||||
|
|
||||||
def wait_for_object_condition(self, *args, **kwargs):
|
def wait_for_object_condition(self, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user