mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
test-runner: use may_block=True for context iteration (and move location)
This allows the callers condition to be checked immediately without the mainloop running. In addition may_block=True allows the mainloop to poll/sleep rather than immediately return back to the caller. This handles async IO much better than may_block=False, at least for our use-case.
This commit is contained in:
parent
54552db7ba
commit
5a14daf9b8
@ -722,8 +722,6 @@ class Namespace:
|
|||||||
context = mainloop.get_context()
|
context = mainloop.get_context()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
context.iteration(may_block=False)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = func(*args)
|
ret = func(*args)
|
||||||
if ret:
|
if ret:
|
||||||
@ -735,8 +733,6 @@ class Namespace:
|
|||||||
GLib.source_remove(timeout)
|
GLib.source_remove(timeout)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
sleep(0.1)
|
|
||||||
|
|
||||||
if done.value == True:
|
if done.value == True:
|
||||||
if isinstance(exception, Exception):
|
if isinstance(exception, Exception):
|
||||||
raise exception
|
raise exception
|
||||||
@ -745,6 +741,8 @@ class Namespace:
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
context.iteration(may_block=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = 'Namespace: %s\n' % self.name
|
ret = 'Namespace: %s\n' % self.name
|
||||||
ret += 'Processes:\n'
|
ret += 'Processes:\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user