Skip to content

Commit 487897d

Browse files
author
Michael Hammann
committed
feat: depends_on flag excepts multiple dependencies for each process now
1 parent 0785929 commit 487897d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

supervisor/process.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ def spawn(self):
196196
Return the process id. If the fork() call fails, return None.
197197
"""
198198
# check if the process is dependent upon any other process and if so make sure that one is in the RUNNING state
199-
if self.config.depends_on is not None and self.config.depends_on.state not in RUNNING_STATES:
200-
self.config.depends_on.spawn()
199+
if self.config.depends_on is not None:
200+
for process in enumerate(self.config.depends_on):
201+
if self.config.depends_on[process[0]].state not in RUNNING_STATES:
202+
self.config.depends_on[process[0]].spawn()
201203

202204
options = self.config.options
203205
processname = as_string(self.config.name)

supervisor/supervisord.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,20 @@ def run(self):
8989
g = Graph(len(self.options.process_group_configs))
9090
# replace depends_on string with actual process object
9191
for config in (self.options.process_group_configs):
92-
# this can be of form group:process or simply process
93-
try:
94-
dependent_group, dependent_process=depends_on.split(":")
95-
except:
96-
dependent_group=dependent_process=depends_on
9792
if config.process_configs[0].depends_on is not None:
98-
g.addEdge(config.process_configs[0].name, dependent_process)
99-
config.process_configs[0].depends_on = self.process_groups[dependent_group].processes[dependent_process]
93+
processes=[]
94+
# split to get all processes in case there are multiple dependencies
95+
dependent_processes = (config.process_configs[0].depends_on).split()
96+
for process in dependent_processes:
97+
# this can be of form group:process or simply process
98+
try:
99+
dependent_group, dependent_process=process.split(":")
100+
except:
101+
dependent_group=dependent_process=process
102+
g.addEdge(config.process_configs[0].name, dependent_process)
103+
print(f'adding edge {config.process_configs[0].name, dependent_process}')
104+
processes.append(self.process_groups[dependent_group].processes[dependent_process])
105+
config.process_configs[0].depends_on = processes
100106
# check for cyclical process dependencies
101107
if g.cyclic() == 1:
102108
raise AttributeError('Process config contains dependeny cycle(s)! Check config files again!')

0 commit comments

Comments
 (0)