Skip to content

Commit 9a86fe8

Browse files
committed
optimize if statements for logging errors
1 parent 8708337 commit 9a86fe8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

watchdog/monitor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ async def monitor_process(self, process_type: str):
176176
timer = 0
177177

178178
if process is None or process.poll() is not None:
179-
warning(f"Process {process_type} is dead, restarting...")
180-
if process is not None and process.stderr is not None:
181-
error(
182-
f"Process {process_type} is dead, error: {process.stderr.read()}"
183-
)
184179
self.stop_process(process_type)
185180
self._start_process(process_type)
181+
if process is not None and process.poll() is not None:
182+
warning(f"Process {process_type} is dead, restarting...")
183+
error(
184+
f"{process.stderr.read() if process.stderr is not None else 'No stderr'}"
185+
)
186186

187187
await asyncio.sleep(1)
188188

0 commit comments

Comments
 (0)