6
6
7
7
import supervisor .xmlrpc # type: ignore[import]
8
8
9
- from knot_resolver .controller .exceptions import SubprocessControllerException , SubprocessControllerExecException
9
+ from knot_resolver .controller .exceptions import SubprocessControllerError , SubprocessControllerExecError
10
10
from knot_resolver .controller .interface import (
11
11
KresID ,
12
12
Subprocess ,
@@ -30,14 +30,14 @@ async def _start_supervisord(config: KresConfig) -> None:
30
30
logger .debug ("Starting supervisord" )
31
31
res = await call (["supervisord" , "--configuration" , str (supervisord_config_file (config ).absolute ())])
32
32
if res != 0 :
33
- raise SubprocessControllerException (f"Supervisord exited with exit code { res } " )
33
+ raise SubprocessControllerError (f"Supervisord exited with exit code { res } " )
34
34
35
35
36
36
async def _exec_supervisord (config : KresConfig ) -> NoReturn :
37
37
logger .debug ("Writing supervisord config" )
38
38
await write_config_file (config )
39
39
logger .debug ("Execing supervisord" )
40
- raise SubprocessControllerExecException (
40
+ raise SubprocessControllerExecError (
41
41
[
42
42
str (which .which ("supervisord" )),
43
43
"supervisord" ,
@@ -53,7 +53,7 @@ async def _reload_supervisord(config: KresConfig) -> None:
53
53
supervisord = _create_supervisord_proxy (config )
54
54
supervisord .reloadConfig ()
55
55
except Fault as e :
56
- raise SubprocessControllerException ("supervisord reload failed" ) from e
56
+ raise SubprocessControllerError ("supervisord reload failed" ) from e
57
57
58
58
59
59
@async_in_a_thread
@@ -113,11 +113,10 @@ async def _is_supervisord_running(config: KresConfig) -> bool:
113
113
pid = await _get_supervisord_pid (config )
114
114
if pid is None :
115
115
return False
116
- elif not _is_process_runinng (pid ):
116
+ if not _is_process_runinng (pid ):
117
117
supervisord_pid_file (config ).unlink ()
118
118
return False
119
- else :
120
- return True
119
+ return True
121
120
122
121
123
122
def _create_proxy (config : KresConfig ) -> ServerProxy :
@@ -164,7 +163,7 @@ def _list_running_subprocesses(config: KresConfig) -> Dict[SupervisordKresID, Su
164
163
supervisord = _create_supervisord_proxy (config )
165
164
processes : Any = supervisord .getAllProcessInfo ()
166
165
except Fault as e :
167
- raise SubprocessControllerException (f"failed to get info from all running processes: { e } " ) from e
166
+ raise SubprocessControllerError (f"failed to get info from all running processes: { e } " ) from e
168
167
169
168
# there will be a manager process as well, but we don't want to report anything on ourselves
170
169
processes = [pr for pr in processes if pr ["name" ] != "manager" ]
@@ -199,7 +198,7 @@ def status(self) -> SubprocessStatus:
199
198
supervisord = _create_supervisord_proxy (self ._config )
200
199
status = supervisord .getProcessInfo (self .name )
201
200
except Fault as e :
202
- raise SubprocessControllerException (f"failed to get status from '{ self .id } ' process: { e } " ) from e
201
+ raise SubprocessControllerError (f"failed to get status from '{ self .id } ' process: { e } " ) from e
203
202
return _convert_subprocess_status (status )
204
203
205
204
@async_in_a_thread
@@ -210,7 +209,7 @@ def _start(self) -> None:
210
209
supervisord = _create_fast_proxy (self ._config )
211
210
supervisord .startProcess (self .name )
212
211
except Fault as e :
213
- raise SubprocessControllerException (f"failed to start '{ self .id } '" ) from e
212
+ raise SubprocessControllerError (f"failed to start '{ self .id } '" ) from e
214
213
215
214
@async_in_a_thread
216
215
def _stop (self ) -> None :
@@ -253,8 +252,7 @@ async def get_all_running_instances(self) -> Iterable[Subprocess]:
253
252
for id_ in states
254
253
if states [id_ ] == SubprocessStatus .RUNNING
255
254
]
256
- else :
257
- return []
255
+ return []
258
256
259
257
async def initialize_controller (self , config : KresConfig ) -> None :
260
258
self ._controller_config = config
0 commit comments