Skip to content
Snippets Groups Projects
Commit 9390483d authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Push state='testing' at startup with CLI arg --test is used.

parent a8becd00
No related branches found
No related tags found
No related merge requests found
...@@ -107,6 +107,7 @@ def main(): ...@@ -107,6 +107,7 @@ def main():
push_log_max_interval=confparser.interval_secs('push_log_max_interval_seconds'), push_log_max_interval=confparser.interval_secs('push_log_max_interval_seconds'),
push_log_max_entries=confparser.value('push_log_max_entries', int), push_log_max_entries=confparser.value('push_log_max_entries', int),
push_act_max_interval=confparser.interval_secs('push_act_max_interval_seconds'), push_act_max_interval=confparser.interval_secs('push_act_max_interval_seconds'),
initial_state='testing' if args.test else 'awake',
) )
mir = may_i_run.MayIRun( mir = may_i_run.MayIRun(
......
...@@ -54,6 +54,9 @@ class FlamencoWorker: ...@@ -54,6 +54,9 @@ class FlamencoWorker:
state = attr.ib(default=WorkerState.STARTING, state = attr.ib(default=WorkerState.STARTING,
validator=attr.validators.instance_of(WorkerState)) validator=attr.validators.instance_of(WorkerState))
# Indicates the state in which the Worker should start
initial_state = attr.ib(validator=attr.validators.instance_of(str), default='awake')
# When Manager tells us we may no longer run our current task, this is set to True. # When Manager tells us we may no longer run our current task, this is set to True.
# As a result, the cancelled state isn't pushed to Manager any more. It is reset # As a result, the cancelled state isn't pushed to Manager any more. It is reset
# to False when a new task is started. # to False when a new task is started.
...@@ -144,8 +147,14 @@ class FlamencoWorker: ...@@ -144,8 +147,14 @@ class FlamencoWorker:
if not do_register: if not do_register:
await self.signon(may_retry_loop=may_retry_loop) await self.signon(may_retry_loop=may_retry_loop)
# If we're not supposed to start in 'awake' state, let the Manager know.
if self.initial_state != 'awake':
self._log.info('Telling Manager we are in state %r', self.initial_state)
self.ack_status_change(self.initial_state)
self.schedule_fetch_task() self.schedule_fetch_task()
@staticmethod @staticmethod
def hostname() -> str: def hostname() -> str:
import socket import socket
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment