EventLoop: Fix log error "Origin parent loop" during wait()
Setting the log.ctx manually is not needed anymore and it's actually harmful since all palces where it was used, a log.Origin already in path was being passed, causing a origin loop. Change-Id: I0511b9f7bc59e3c7f2269ff3155d0c95db58d063
This commit is contained in:
parent
3a81a7e4dc
commit
664e383021
|
@ -85,9 +85,8 @@ class EventLoop:
|
|||
self.gctx.iteration(may_block)
|
||||
self.deferred_handling.handle_queue()
|
||||
|
||||
def wait_no_raise(self, log_obj, condition, condition_args, condition_kwargs, timeout, timestep):
|
||||
def wait_no_raise(self, condition, condition_args, condition_kwargs, timeout, timestep):
|
||||
if not timeout or timeout < 0:
|
||||
self = log_obj
|
||||
raise log.Error('wait() *must* time out at some point.', timeout=timeout)
|
||||
if timestep < 0.1:
|
||||
timestep = 0.1
|
||||
|
@ -105,14 +104,13 @@ class EventLoop:
|
|||
success = wait_req.condition_ack
|
||||
return success
|
||||
|
||||
def wait(self, log_obj, condition, *condition_args, timeout=300, timestep=1, **condition_kwargs):
|
||||
if not self.wait_no_raise(log_obj, condition, condition_args, condition_kwargs, timeout, timestep):
|
||||
log.ctx(log_obj)
|
||||
def wait(self, condition, *condition_args, timeout=300, timestep=1, **condition_kwargs):
|
||||
if not self.wait_no_raise(condition, condition_args, condition_kwargs, timeout, timestep):
|
||||
raise log.Error('Wait timeout', condition=condition, timeout=timeout, timestep=timestep)
|
||||
|
||||
def sleep(self, log_obj, seconds):
|
||||
def sleep(self, seconds):
|
||||
assert seconds > 0.
|
||||
self.wait_no_raise(log_obj, lambda: False, [], {}, timeout=seconds, timestep=seconds)
|
||||
self.wait_no_raise(lambda: False, [], {}, timeout=seconds, timestep=seconds)
|
||||
|
||||
|
||||
MainLoop = EventLoop()
|
||||
|
|
|
@ -347,7 +347,7 @@ class Process(log.Origin):
|
|||
return self.result is not None
|
||||
|
||||
def wait(self, timeout=300):
|
||||
MainLoop.wait(self, self.terminated, timeout=timeout)
|
||||
MainLoop.wait(self.terminated, timeout=timeout)
|
||||
|
||||
def stdin_write(self, cmd):
|
||||
'''
|
||||
|
|
|
@ -139,7 +139,7 @@ class NanoBts(bts.Bts):
|
|||
# Let some time for BTS to restart. It takes much more than 20 secs, and
|
||||
# this way we make sure we don't catch responses in abisip-find prior to
|
||||
# BTS restarting.
|
||||
MainLoop.sleep(self, 20)
|
||||
MainLoop.sleep(20)
|
||||
|
||||
self.dbg('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc)
|
||||
ipfind = AbisIpFind(self.testenv, self.run_dir, local_bind_ip, 'postconf')
|
||||
|
@ -150,7 +150,7 @@ class NanoBts(bts.Bts):
|
|||
else:
|
||||
self.dbg('nanoBTS id %d trx %d no need to change OML IP (%s) and restart' % (unitid, trx_i, running_oml_ip))
|
||||
|
||||
MainLoop.wait(self, self.bsc.bts_is_connected, self, timeout=600)
|
||||
MainLoop.wait(self.bsc.bts_is_connected, self, timeout=600)
|
||||
self.log('nanoBTS connected to BSC')
|
||||
|
||||
#According to roh, it can be configured to use a static IP in a permanent way:
|
||||
|
@ -239,11 +239,11 @@ class AbisIpFind(log.Origin):
|
|||
return self.get_line_by_ip(ipaddr) is not None
|
||||
|
||||
def wait_bts_ready(self, ipaddr):
|
||||
MainLoop.wait(self, self.bts_ready, ipaddr)
|
||||
MainLoop.wait(self.bts_ready, ipaddr)
|
||||
# There's a period of time after boot in which nanobts answers to
|
||||
# abisip-find but tcp RSTs ipacces-config conns. Let's wait in here a
|
||||
# bit more time to avoid failing after stating the BTS is ready.
|
||||
MainLoop.sleep(self, 2)
|
||||
MainLoop.sleep(2)
|
||||
|
||||
class IpAccessConfig(log.Origin):
|
||||
testenv = None
|
||||
|
|
|
@ -173,7 +173,7 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
|
|||
self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.testenv, self.conf_for_osmotrx())
|
||||
self.trx.start(keepalive)
|
||||
self.log('Waiting for %s to start up...' % self.trx.name())
|
||||
MainLoop.wait(self, self.trx.trx_ready)
|
||||
MainLoop.wait(self.trx.trx_ready)
|
||||
|
||||
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
|
||||
lib = self.inst.child('lib')
|
||||
|
@ -374,7 +374,7 @@ class TrxSC5(Trx):
|
|||
break
|
||||
keep_trying = keep_trying - 1
|
||||
self.log('Configuring SC5 TRX failed, retrying %d more times' % keep_trying)
|
||||
MainLoop.sleep(self, 5)
|
||||
MainLoop.sleep(5)
|
||||
if keep_trying == 0:
|
||||
raise log.Error('Failed configuring SC5!')
|
||||
self.ready = True
|
||||
|
|
|
@ -190,7 +190,7 @@ class Esme(log.Origin):
|
|||
umref, self.pdus_pending = self.sms_send(sms_obj, mode, receipt)
|
||||
self.dbg('pdus_pending:', self.pdus_pending)
|
||||
self.client.set_message_sent_handler(self._process_pdus_pending)
|
||||
MainLoop.wait(self, lambda: len(self.pdus_pending) == 0, timeout=10)
|
||||
MainLoop.wait(lambda: len(self.pdus_pending) == 0, timeout=10)
|
||||
return umref
|
||||
finally:
|
||||
self.client.set_message_sent_handler(old_func)
|
||||
|
|
|
@ -317,7 +317,7 @@ class ModemDbusInteraction(log.Origin):
|
|||
self.log('Setting', name, val)
|
||||
self.interface(iface).SetProperty(name, Variant('b', val))
|
||||
|
||||
MainLoop.wait(self, self.property_is, name, bool_val)
|
||||
MainLoop.wait(self.property_is, name, bool_val)
|
||||
|
||||
def set_powered(self, powered=True):
|
||||
self.set_bool('Powered', powered)
|
||||
|
@ -461,10 +461,10 @@ class Modem(MS):
|
|||
if not self.is_powered():
|
||||
self.set_powered()
|
||||
# wait for SimManager iface to appear after we power on
|
||||
MainLoop.wait(self, self.dbus.has_interface, I_SIMMGR, timeout=10)
|
||||
MainLoop.wait(self.dbus.has_interface, I_SIMMGR, timeout=10)
|
||||
simmgr = self.dbus.interface(I_SIMMGR)
|
||||
# If properties are requested quickly, it may happen that Sim property is still not there.
|
||||
MainLoop.wait(self, lambda: simmgr.GetProperties().get('SubscriberIdentity', None) is not None, timeout=10)
|
||||
MainLoop.wait(lambda: simmgr.GetProperties().get('SubscriberIdentity', None) is not None, timeout=10)
|
||||
props = simmgr.GetProperties()
|
||||
self.dbg('got SIM properties', props)
|
||||
self._imsi = props.get('SubscriberIdentity', None)
|
||||
|
@ -606,7 +606,7 @@ class Modem(MS):
|
|||
self.set_powered(False)
|
||||
req_ifaces = self._required_ifaces()
|
||||
for iface in req_ifaces:
|
||||
MainLoop.wait(self, lambda: not self.dbus.has_interface(iface), timeout=10)
|
||||
MainLoop.wait(lambda: not self.dbus.has_interface(iface), timeout=10)
|
||||
|
||||
def power_cycle(self):
|
||||
'Power the modem and put it online, power cycle it if it was already on'
|
||||
|
@ -618,7 +618,7 @@ class Modem(MS):
|
|||
self.dbg('Powering on')
|
||||
self.set_powered()
|
||||
self.set_online()
|
||||
MainLoop.wait(self, self.dbus.has_interface, *req_ifaces, timeout=10)
|
||||
MainLoop.wait(self.dbus.has_interface, *req_ifaces, timeout=10)
|
||||
|
||||
def connect(self, mcc_mnc=None):
|
||||
'Connect to MCC+MNC'
|
||||
|
@ -671,7 +671,7 @@ class Modem(MS):
|
|||
|
||||
# Activate can only be called after we are attached
|
||||
ctx.SetProperty('Active', Variant('b', True))
|
||||
MainLoop.wait(self, lambda: ctx.GetProperties()['Active'] == True)
|
||||
MainLoop.wait(lambda: ctx.GetProperties()['Active'] == True)
|
||||
self.log('context activated', path=ctx_path, apn=apn, user=user, properties=ctx.GetProperties())
|
||||
return ctx_path
|
||||
|
||||
|
@ -679,7 +679,7 @@ class Modem(MS):
|
|||
self.dbg('deactivate_context', path=ctx_id)
|
||||
ctx = systembus_get(ctx_id)
|
||||
ctx.SetProperty('Active', Variant('b', False))
|
||||
MainLoop.wait(self, lambda: ctx.GetProperties()['Active'] == False)
|
||||
MainLoop.wait(lambda: ctx.GetProperties()['Active'] == False)
|
||||
self.dbg('deactivate_context active=false, removing', path=ctx_id)
|
||||
connmgr = self.dbus.interface(I_CONNMGR)
|
||||
connmgr.RemoveContext(ctx_id)
|
||||
|
@ -770,7 +770,7 @@ class Modem(MS):
|
|||
else:
|
||||
caller_msisdn = str(caller_msisdn_or_modem)
|
||||
self.dbg('Waiting for incoming call from:', caller_msisdn)
|
||||
MainLoop.wait(self, lambda: self._find_call_msisdn_state(caller_msisdn, 'incoming') is not None, timeout=timeout)
|
||||
MainLoop.wait(lambda: self._find_call_msisdn_state(caller_msisdn, 'incoming') is not None, timeout=timeout)
|
||||
return self._find_call_msisdn_state(caller_msisdn, 'incoming')
|
||||
|
||||
def call_answer(self, call_id):
|
||||
|
|
|
@ -123,7 +123,7 @@ class srsUE(MS):
|
|||
def sleep_after_stop(self):
|
||||
# Only sleep once
|
||||
if self.stop_sleep_time > 0:
|
||||
MainLoop.sleep(self, self.stop_sleep_time)
|
||||
MainLoop.sleep(self.stop_sleep_time)
|
||||
self.stop_sleep_time = 0
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -89,7 +89,7 @@ class Osmocon(log.Origin):
|
|||
self.testenv.remember_to_stop(self.process)
|
||||
self.process.launch()
|
||||
self.log('Waiting for osmocon to be up and running')
|
||||
MainLoop.wait(self, os.path.exists, self.l2_socket_path())
|
||||
MainLoop.wait(os.path.exists, self.l2_socket_path())
|
||||
|
||||
def running(self):
|
||||
return not self.process.terminated()
|
||||
|
|
|
@ -47,7 +47,7 @@ class PowerSupply(log.Origin, metaclass=ABCMeta):
|
|||
def power_cycle(self, sleep=0):
|
||||
"""Turns off the device, waits N.N seconds, then turn on the device."""
|
||||
self.power_set(False)
|
||||
MainLoop.sleep(self, sleep)
|
||||
MainLoop.sleep(sleep)
|
||||
self.power_set(True)
|
||||
|
||||
def get_instance_by_type(pwsupply_type, pwsupply_opt):
|
||||
|
|
|
@ -48,7 +48,7 @@ class PowerSupplySispm(PowerSupply):
|
|||
except USBError as e:
|
||||
if e.errno == 16 or e.errno==110:
|
||||
self.log('skip usb error, retry', repr(e))
|
||||
MainLoop.sleep(self, 0.1)
|
||||
MainLoop.sleep(0.1)
|
||||
continue
|
||||
raise e
|
||||
|
||||
|
|
|
@ -345,13 +345,13 @@ def setup(suite_run, _test):
|
|||
log = test.log
|
||||
dbg = test.dbg
|
||||
err = test.err
|
||||
wait = lambda *args, **kwargs: MainLoop.wait(suite_run, *args, **kwargs)
|
||||
wait_no_raise = lambda *args, **kwargs: MainLoop.wait_no_raise(suite_run, *args, **kwargs)
|
||||
sleep = lambda *args, **kwargs: MainLoop.sleep(suite_run, *args, **kwargs)
|
||||
tenv = TestEnv(suite_run, _test)
|
||||
wait = MainLoop.wait
|
||||
wait_no_raise = MainLoop.wait_no_raise
|
||||
sleep = MainLoop.sleep
|
||||
poll = MainLoop.poll
|
||||
Sms = Sms_class
|
||||
process = process_module
|
||||
tenv = TestEnv(suite_run, _test)
|
||||
prompt = tenv.prompt
|
||||
return tenv
|
||||
|
||||
|
|
Loading…
Reference in New Issue