return True
-def force_halt_build():
+def force_halt_build(timeout):
"""Halt the currently running Vagrant VM, to be called from a Timer"""
- logging.error(_('Force halting build after timeout!'))
+ logging.error(_('Force halting build after {0} sec timeout!').format(timeout))
timeout_event.set()
vm = vmtools.get_build_vm('builder')
vm.halt()
if time.time() > endtime:
max_build_time_reached = True
break
- if options.server: # enable watchdog timer
- timer = threading.Timer(7200, force_halt_build)
+
+ # Enable watchdog timer (2 hours by default).
+ if build.timeout is None:
+ timeout = 7200
+ else:
+ timeout = int(build.timeout)
+ if options.server and timeout > 0:
+ logging.debug(_('Setting {0} sec timeout for this build').format(timeout))
+ timer = threading.Timer(timeout, force_halt_build, [timeout])
timer.start()
else:
timer = None
build_flags_order = [
'disable',
'commit',
+ 'timeout',
'subdir',
'submodules',
'sudo',
super().__init__()
self.disable = False
self.commit = None
+ self.timeout = None
self.subdir = None
self.submodules = False
self.sudo = ''
'forcevercode': TYPE_BOOL,
'novcheck': TYPE_BOOL,
'antifeatures': TYPE_LIST,
+ 'timeout': TYPE_INT,
}
build[pk] = pv
elif t == TYPE_BOOL:
build[pk] = _decode_bool(pv)
+ elif t == TYPE_INT:
+ build[pk] = int(pv)
def parse_buildline(lines):
v = "".join(lines)