Skip to content

Commit

Permalink
Raise exception when process cannot be started
Browse files Browse the repository at this point in the history
  • Loading branch information
tgibson11 committed Jul 11, 2023
1 parent d056e21 commit a6f29bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 7 additions & 5 deletions syscontrol/run_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
process_running,
process_stop,
processNotRunning,
processNotStarted,
)

from sysproduction.data.control_process import dataControlProcess, diagControlProcess
Expand Down Expand Up @@ -96,8 +97,9 @@ def wait_reporter(self) -> reportProcessStatus:
return self._wait_reporter

def run_process(self):
result_of_starting = _start_or_wait(self)
if result_of_starting is failure:
try:
_start_or_wait(self)
except processNotStarted:
return None

self._run_on_start()
Expand Down Expand Up @@ -160,16 +162,16 @@ def _finish_control_process(self):
### STARTUP CODE


def _start_or_wait(process_to_run: processToRun) -> status:
def _start_or_wait(process_to_run: processToRun):
waiting = True
while waiting:
okay_to_start = _is_okay_to_start(process_to_run)
if okay_to_start:
return success
return

okay_to_wait = _is_okay_to_wait_before_starting(process_to_run)
if not okay_to_wait:
return failure
raise processNotStarted

time.sleep(60)

Expand Down
6 changes: 5 additions & 1 deletion sysobjects/production/process_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@
missing_date_str = ""


class processNotStarted(Exception):
"""Unable to start the process"""


class processNotRunning(Exception):
pass
"""Process expected to be running, but was not"""


class dictOfRunningMethods(dict):
Expand Down

0 comments on commit a6f29bf

Please sign in to comment.